Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to do http requetss python

import requests (pip3 install requests or pip install requests)

# GET REQUEST
headers = {
  'user-agent': 'testing'
r = requests.get('https://website.com', headers=headers)
print(r.text)
print(r.status_code)
#send a request to the site you want by changing the website, and if needed add a real user agent so you will not be detected as a bot right away
#r.text is the variable that is storing the information that the website gives when you send the request
#r.status_code stores the status code the website gives.
'''
429 = too many requests
201 or 200 = good request
400 = wrong URL/DATA
403 = banned
'''
  
# POST REQUEST
data = {
  'testfield' : 2
}
r = requests.get('https://website.com', data=data, headers=headers)
print(r.text, r.status_code)
#post data to a website
#r.text is the variable storing the response message
#r.status_code is the status code the website gives 
 
PREVIOUS NEXT
Tagged: #http #requetss #python
ADD COMMENT
Topic
Name
8+5 =