Questions tagged [python-requests]

USE ONLY FOR THE PYTHON REQUESTS LIBRARY. Requests is a full-featured Python HTTP library with an easy-to-use, logical API.

Official web site

Requests is an HTTP library written in Python under the Apache2 license.

It's meant to simplify HTTP 1.1 related tasks with several functionality out of the box. For example, there’s no need to manually add query strings to your URLs or to form-encode your POST data. Keep-alive and HTTP connection pooling are 100% automatic.

Features:

  • International Domains and URLs
  • Keep-Alive & Connection Pooling
  • Sessions with Cookie Persistence
  • Browser-style SSL Verification
  • Automatic Content Decoding
  • Basic/Digest Authentication
  • Elegant Key/Value Cookies
  • Automatic Decompression
  • Unicode Response Bodies
  • Multipart File Uploads
  • Streaming Downloads
  • Connection Timeouts
  • .netrc support
  • Chunked Requests
  • Python 2.6—3.8
  • Thread-safe.
21751 questions
28
votes
1 answer

How to resume file download in Python?

I am using python 2.7 requests module to download a binary file using the following code, how to make this code "auto-resume" the download from partially downloaded file. r = requests.get(self.fileurl, stream=True, verify=False,…
Stacked
  • 841
  • 2
  • 12
  • 23
28
votes
4 answers

Does requests.codes.ok include a 304?

I have a program which uses the requests module to send a get request which (correctly) responds with a 304 "Not Modified". After making the request, I check to make sure response.status_code == requests.codes.ok, but this check fails. Does requests…
stett
  • 1,351
  • 1
  • 11
  • 24
28
votes
5 answers

Limiting/throttling the rate of HTTP requests in GRequests

I'm writing a small script in Python 2.7.3 with GRequests and lxml that will allow me to gather some collectible card prices from various websites and compare them. Problem is one of the websites limits the number of requests and sends back HTTP…
Bartłomiej Siwek
  • 1,447
  • 2
  • 17
  • 26
28
votes
4 answers

Using python 'requests' to send JSON boolean

I've got a really simple question, but I can't figure it out how to do it. The problem I have is that I want to send the following payload using Python and Requests: { 'on': true } Doing it like this: payload = { 'on':true } r =…
Erik Pragt
  • 13,513
  • 11
  • 58
  • 64
27
votes
2 answers

How to properly do requests to a https with a proxy server such as luminati.io?

This is the API provided by luminati.io a premium proxy provider. However, it returns as a byte code instead of a dictionary, so it is converted into a dictonary as to be able to extract the ip and port: Every request will end up with a new peer…
Pherdindy
  • 1,168
  • 7
  • 23
  • 52
27
votes
1 answer

Python Requests - pass parameter via GET

I am trying to call an API and pass some parameters to it. My endpoint should look like: https://example.com?q=food (food is the parameter) import requests parametervalue = "food" r = requests.get("https://example.com/q=", parametervalue) When I…
Cody Raspien
  • 1,753
  • 5
  • 26
  • 51
27
votes
5 answers

Python requests SSL error - certificate verify failed

This code import requests requests.get("https://hcaidcs.phe.org.uk/WebPages/GeneralHomePage.aspx") is giving me this error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777) I know practically nothing about SSL, but I've tried…
Oliver
  • 1,098
  • 1
  • 11
  • 16
27
votes
2 answers

curl vs python "requests" when hitting APIs

I am trying to hit the Bitbucket API for my account, and a successful attempt looks like: curl --user screename:mypassword https://api.bitbucket.org/1.0/user/repositories in the command line. In python, I try: import requests url =…
codyc4321
  • 9,014
  • 22
  • 92
  • 165
27
votes
3 answers

Using requests module, how to handle 'set-cookie' in request response?

I'm attempting to open a login page (GET), fetch the cookies provided by the webserver, then submit a username and password pair to log into the site (POST). Looking at this Stackoverflow question/answer, I would think that I would just do the…
tommy_o
  • 3,640
  • 3
  • 29
  • 33
27
votes
10 answers

How to get response SSL certificate from requests in python?

Trying to get the SSL certificate from a response in requests. What is a good way to do this?
Juan Carlos Coto
  • 11,900
  • 22
  • 62
  • 102
26
votes
4 answers

SSL: WRONG_VERSION_NUMBER ON PYTHON REQUEST

Python version: 3.9.1 I trying to write bot that send requests and it work perfectly fine, the only issue that i have is when i trying to use web debugging programs such as Charles 4.6.1 or Fiddler Everywhere. When I open it to see bot traffic and…
NoNam4
  • 457
  • 1
  • 4
  • 12
26
votes
5 answers

python requests can't find a folder with a certificate when converted to .exe

I have a program that pools ad stats from different marketing systems. Everything works fine untill i convert it to the .exe format and run it. Exception in Tkinter callback Traceback (most recent call last): File…
26
votes
2 answers

Passing cookies while logging in

I would like to integrate python Selenium and Requests modules to authenticate on a website. I am using the following code: import requests from selenium import webdriver driver = webdriver.Firefox() url = "some_url" #a redirect to a login page…
AntoG
  • 833
  • 1
  • 10
  • 16
26
votes
3 answers

how to determine the filename of content downloaded with HTTP in Python?

I download a file using the get function of Python requests library. For storing the file, I'd like to determine the filename the way a web browser would for its 'save' or 'save as ...' dialog. Easy, right? I can just get it from the…
das-g
  • 9,718
  • 4
  • 38
  • 80
26
votes
1 answer

Locust.io Load Testing getting "Connection aborted BadStatusLine" Errors

I'm using Locust.io to load test an application. I will get a random error that I am unable to pinpoint the problem: 1) ConnectionError(ProtocolError(\'Connection aborted.\', BadStatusLine("\'\'",)),) 2) ConnectionError(ProtocolError('Connection…
arcane
  • 457
  • 6
  • 10