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 :: loop through 2 items python 
Python :: failed to allocate bitmap 
Python :: write data to using pickle 
Python :: python convert dict to xml 
Python :: how to find the location of a character in a string in python 
Python :: how to install whl file in python 
Python :: when was python created 
Python :: boto3 read excel file from s3 into pandas 
Python :: named tuple python iterate 
Python :: date colomn to datetime 
Python :: pandas export csv without index 
Python :: check if dataframe contains infinity 
Python :: input multiple values in python 
Python :: reverse key order dict python 
Python :: python sorted dictionary multiple keys 
Python :: get a colomn of csv in pandas 
Python :: calculate age python 
Python :: api testing with python 
Python :: where is tensorflow slim 
Python :: Set a random seed 
Python :: permutations of a set 
Python :: python file count 
Python :: how to find unique values in a column in pandas 
Python :: access sqlite db python 
Python :: python requests response get text 
Python :: tqdm progress bar python 
Python :: pip tensorflow 
Python :: f string in python 
Python :: plot size 
Python :: how to make a separate list of values from dictionaries in python 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =