Answers for "python3 http request"

8

get request python

import requests

x = requests.get('https://w3schools.com')
print(x.status_code)
Posted by: Guest on August-14-2020
17

get requests from python

import requests

response = requests.get('<api-endpoint>')
response.raise_for_status()

data = response.json()
print(data)
Posted by: Guest on March-24-2021
2

urllib.request headers

try:
    from urllib.request import Request, urlopen  # Python 3
except ImportError:
    from urllib2 import Request, urlopen  # Python 2

req = Request('http://api.company.com/items/details?country=US&language=en')
req.add_header('apikey', 'xxx')
content = urlopen(req).read()

print(content)
Posted by: Guest on April-04-2020
1

http client post python

import requests
pload = {'username':'Olivia','password':'123'}
r = requests.post('https://httpbin.org/post',data = pload)
print(r.text)
Posted by: Guest on June-08-2020
0

urllib urlretrieve python 3

#In Python 3.x, the urlretrieve function is located in the urllib.request module:
from urllib.request import urlretrieve
Posted by: Guest on June-25-2020

Python Answers by Framework

Browse Popular Code Answers by Language