Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get request python

import requests

x = requests.get('https://w3schools.com')
print(x.status_code)
Comment

python request example

import requests
   
# Making a GET request
r = requests.get('https://api.github.com/users/naveenkrnl')
  
# check status code for response received
# success code - 200
print(r)
  
# print content of request
print(r.content)
Comment

get requests from python

import requests

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

data = response.json()
print(data)
Comment

Python Requests Library Get Method

import requests
 
url = 'https://codegrepper.com/'
response = requests.get(url)
 
print('URL: ', response.url)
print('Status code: ', response.status_code)
print('HTTP header: ', response.headers)
Comment

python requests get

# pip install requests
import requests
req = requests.get('<url here>', 'html.parser')
print(req.text)
Comment

get requests python

import requests

r = requests.get('https://api.github.com', auth=('user', 'pass'))

print r.status_code
print r.headers['content-type']
Comment

python requests get

# 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

PREVIOUS NEXT
Code Example
Python :: python tkinter clear textbox 
Python :: normalize data python pandas 
Python :: pyqt5 wait cursor 
Python :: check if any values overlap in numpy array 
Python :: rotate labels matplotlib 
Python :: python plot two lines on same graph 
Python :: python - exclude rowin data frame based on value 
Python :: plot normal distribution python 
Python :: python merge strings in columns 
Python :: py check discord token 
Python :: python use .env 
Python :: return the count of a given substring from a string python 
Python :: list existing virtual envs 
Python :: python datetime minus 1 day 
Python :: python clear screen 
Python :: Unable to locate package python3.6-venv 
Python :: calculator in one line in python 
Python :: Solving environment: failed with initial frozen solve. retrying with flexible solve 
Python :: print on two digit python format 
Python :: regex email python 
Python :: python write a list to a file line by line 
Python :: python get num classes from label encoder 
Python :: python magic windows error 
Python :: get current file location 
Python :: python join list with comma 
Python :: pylint: disable=unused-argument 
Python :: camera lags when using with opencv 
Python :: apolatrix 
Python :: string to list in python comma 
Python :: how to convert index to column in pandas 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =