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
26
votes
5 answers

Curl works but not Python requests

I am trying to fetch a JSON response from http://erdos.sdslabs.co/users/shagun.json. Using browser/Python's Requests library leads to an authentication error, but curl seems to work fine. curl http://erdos.sdslabs.co/users/shagun.json returns the…
Shagun Sodhani
  • 3,535
  • 4
  • 30
  • 41
26
votes
3 answers

HTTPSConnectionPool Max retries exceeded

I've got a django app in production running on nginx/uwsgi. We recently started using SSL for all our connections. Since moving to SSL, I often get the following message: HTTPSConnectionPool(host='foobar.com', port=443): Max retries exceeded…
Gevious
  • 3,214
  • 3
  • 21
  • 42
26
votes
5 answers

Using cookies.txt file with Python Requests

I'm trying to access an authenticated site using a cookies.txt file (generated with a Chrome extension) with Python Requests: import requests, cookielib cj = cookielib.MozillaCookieJar('cookies.txt') cj.load() r = requests.get(url, cookies=cj) It…
cjauvin
  • 3,433
  • 4
  • 29
  • 38
25
votes
2 answers

How does requests' stream=True option streams data one block at a time?

I'm using the following code to test how many seconds an HTTP connection can be kept alive: start_time = time.time() try: r = requests.get(BIG_FILE_URL, stream=True) total_length = r.headers['Content-length'] for chunk in…
Tom
  • 1,203
  • 4
  • 21
  • 36
25
votes
5 answers

Python and Dart Integration in Flutter Mobile Application

Can i do these two things: Is there any library in dart for Sentiment Analysis? Can I use Python (for Sentiment Analysis) in dart? My main motive for these questions is that I'm working on an application in a flutter and I use sentiment analysis…
Hamza Tanveer
  • 323
  • 1
  • 3
  • 7
25
votes
3 answers

Getting with Python http requests instead of INT

Im trying to create simple python code that would communicate with 9kw.eu captcha solving service through their api https://www.9kw.eu/api.html#apisubmit-tab. Basically I'm sending base64 encoded image with some keys:values and response from server…
user3281831
  • 839
  • 5
  • 14
  • 24
25
votes
3 answers

Python SSL connection "EOF occurred in violation of protocol"

I'm using Django Celery task to connect to Facebook Graph API with requests lib using Gevent. Issue I'm constantly running at is that every now and then I get EOF occurred in violation of protocol exception. I've searched around and various sources…
user962563
  • 495
  • 1
  • 4
  • 14
24
votes
3 answers

Using the Requests python library in Google App Engine

I'm trying to use the awesome Requests library on Google App Engine. I found a patch for urllib3, which requests relies on, that is compatible with App Engine. https://github.com/shazow/urllib3/issues/61 I can successfully import requests but…
rd108
  • 631
  • 2
  • 7
  • 14
24
votes
3 answers

ReadTimeout: HTTPSConnectionPool(host='', port=443): Read timed out. (read timeout=10)

I'm doing a webscraping on a site and sometimes when running the script I get this error: ReadTimeout: HTTPSConnectionPool(host='...', port=443): Read timed out. (read timeout=10) My code: url = 'mysite.com' all_links_page = [] page_one =…
JB_
  • 533
  • 1
  • 6
  • 18
24
votes
3 answers

Getting ('Connection aborted.', OSError(0, 'Error') errors with python requests

I'm trying to write code to login to a website. First I tested using ARC. It works fine. Image So I wrote python code like this: import requests url = 'https://www.bible.ac.kr/login.aspx/' headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT…
kyungmin
  • 474
  • 1
  • 4
  • 9
24
votes
2 answers

How to serialize requests Response object as HAR

I want to serialize a requests Response object as json, preferably in HAR format. import requests resp = requests.get('http://httpbin.org/get') har = to_har(resp) # <--- magic but couldnt find anything online with my google-fu powers. it seems…
ShmulikA
  • 3,468
  • 3
  • 25
  • 40
24
votes
3 answers

Make a non-blocking request with requests when running Flask with Gunicorn and Gevent

My Flask application will receive a request, do some processing, and then make a request to a slow external endpoint that takes 5 seconds to respond. It looks like running Gunicorn with Gevent will allow it to handle many of these slow requests at…
JLTChiu
  • 983
  • 3
  • 12
  • 28
24
votes
1 answer

How to use requests to send a PATCH request with headers

I have a Rails 4 application which uses token based authentication for APIs and need to be able to update records through Python 3 script. My current script looks like this import requests import json url =…
Bart C
  • 1,509
  • 2
  • 16
  • 17
24
votes
6 answers

Python Requests getting SSLerror

Trying to make a simple get request using Requests session but I keep getting SSLerror for a specific site. I think maybe the problem is with the site (I did a scan using https://www.ssllabs.com, results are down bellow), but I cant be sure because…
Captain_Meow_Meow
  • 2,341
  • 5
  • 31
  • 44
24
votes
4 answers

Requests - get content-type/size without fetching the whole page/content

I have a simple website crawler, it works fine, but sometime it stuck because of large content such as ISO images, .exe files and other large stuff. Guessing content-type using file extension is probably not the best idea. Is it possible to get…
5w0rdf1sh
  • 451
  • 1
  • 4
  • 9