Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python request post

headers = {
  'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0',
}
pload = {'key':'value'}
r = requests.post('https://URL', data=pload, headers=headers)
print(r.text)
Comment

python post request

# In your terminal run: pip install requests
import requests

data = {"a_key": "a_value"}
url = "http://your-path.com/post"
response = requests.post(url, json=data)

print(response)
Comment

python requests post

>>> r = requests.post('https://httpbin.org/post', data = {'key':'value'})
Comment

Python Requests Library Post Method

import requests

url = 'http://httpbin.org/post'
payload = {
    'website':'softhunt.net',
    'courses':['Python','JAVA']
    }
response = requests.post(url, data=payload)
print(response.text)
Comment

python requests post

# requires pip install requests
import requests

# webpage url to sent request to
url = 'https://www.google.com'

# send get requests
x = requests.get(url=url)

# print status code of request
print(x.status_code)

# print webpage source code text
print(x.text)

# print webpage as json
print(x.json)

# print webpage headers
print(x.headers)

# send a get request and timeout if it takes longer than 2.5 seconds
x = requests.get(url=url, timeout=2.5)

# demonstrate how to use the 'params' parameter: query string
x = requests.get(url=url, params={"model": "Mustang"})


####################

# require pip install requests
import requests

url = 'https://www.google.com'
form_data = {'username': 'john', 'password': "pwd"}

# send post request
x = requests.post(url=url, json=form_data)

# send post request and timeout if it takes longer than 3 seconds
x = requests.post(url=url, json=form_data, timeout=3)

# use the 'auth' parameter to send requests with HTTP Basic Auth:
x = requests.post(url, data=from_data, auth=('user', 'pass'))

print(x.text)
print(x.headers)
print(x.status_code)
Comment

request post python

import requests
import logging

API_KEY = "xxxxxxxxxxxxxxxxxxxxxxx"
API_ENDPOINT = "https://sample.endpoint.php"
try:
       # your source data eg format
       source_data = {"key":list(values)}
  
       # header to be sent to api
       headers = {"api-key" : API_KEY}
  
       # sending post request and saving response as response object
       r = requests.post(url = API_ENDPOINT, json=source_data, headers=headers)
  
       logging.info("Data push was completed with status code :"+str(r.status_code))
except requests.exceptions.RequestException as e:
       logging.info("error occured : "+ str(e) +"
status code:"+str(r.status_code))
Comment

PREVIOUS NEXT
Code Example
Python :: Get all the numerical column from the dataframe using python 
Python :: making a basic network scanner using python 
Python :: iterate through characters in a string python 
Python :: python program for swapping position of two numbers 
Python :: iterate through an array python 
Python :: python add to file 
Python :: python convert object into ditct 
Python :: Plotly set axes labels 
Python :: binary to decimal python 
Python :: beautiful soup get class name 
Python :: python drop all variable that start with the same name 
Python :: python list count() 
Python :: standard deviation python 
Python :: pyauto gui save screenshot 
Python :: python how to get user input 
Python :: Select rows in pandas MultiIndex DataFrame 
Python :: multiclass ROC AUC curve 
Python :: date.month date time 
Python :: count dictionary keys 
Python :: logging - multiple log file 
Python :: tkinter how to remove button boder 
Python :: clone website in python 
Python :: replace values in a column by condition python 
Python :: python scraping 
Python :: delete virtual environment in python windows 
Python :: python remove characters from end of string 
Python :: write json pythonb 
Python :: python isnan 
Python :: python mixins 
Python :: import get_object_or_404 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =