Search
 
SCRIPT & CODE EXAMPLE
 

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 
Comment

PREVIOUS NEXT
Code Example
Python :: parquet to dataframe 
Python :: add whitespaces between char python 
Python :: django link home page 
Python :: Draw Spiderman With Python And Turtle 
Python :: ipywidegtes dropdown 
Python :: Flatten List in Python Using List Comprehension 
Python :: replace number with string python 
Python :: generate sha1 python 
Python :: df empty 
Python :: value_count pandas change column name 
Python :: password text in entry in tkinter 
Python :: if list item is found in string get that item python 
Python :: extract url from page python 
Python :: add hour minutes second python 
Python :: convert decimal to binary in python 
Python :: input array of string in python 
Python :: python dictionary get key by value 
Python :: python remove duplicates words from string 
Python :: pytest check exception 
Python :: Python RegEx Getting index of matched object 
Python :: python generate id 
Python :: python3 send mail 
Python :: print str and float python 
Python :: convert string to list python 
Python :: open file python 
Python :: add 2 set python 
Python :: pandas xlsx to dataframe 
Python :: smtplib not sending email 
Python :: arch linux python 3.7 
Python :: python longest word in string 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =