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
45
votes
9 answers

Putting a `Cookie` in a `CookieJar`

I'm using the Python Requests library to make HTTP requests. I obtain a cookie from the server as text. How do I turn that into a CookieJar with the cookie in it?
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
44
votes
2 answers

Python HTTP Server/Client: Remote end closed connection without response error

I made simple HTTP Server using BaseHTTPRequestHandler. The problem is, that when I want to post some data using requests from client, I get ConnectionError. I did simple request from requests lib documentation. Also interesting thing is, that HTTP…
martin1337
  • 2,384
  • 6
  • 38
  • 85
44
votes
3 answers

Why do I constantly see "Resetting dropped connection" when uploading data to my database?

I'm uploading hundreds of millions of items to my database via a REST API from a cloud server on Heroku to a database in AWS EC2. I'm using Python and I am constantly seeing the following INFO log message in the…
Andrew Thompson
  • 2,396
  • 1
  • 21
  • 23
44
votes
3 answers

Python-Requests, extract url parameters from a string

I am using this awesome library called requests to maintain python 2 & 3 compatibility and simplify my application requests management. I have a case where I need to parse a url and replace one of it's parameter.…
Gab
  • 5,604
  • 6
  • 36
  • 52
44
votes
4 answers

Get html using Python requests?

I am trying to teach myself some basic web scraping. Using Python's requests module, I was able to grab html for various websites until I tried this: >>> r =…
Rich Thompson
  • 547
  • 1
  • 4
  • 6
44
votes
8 answers

Use %20 instead of + for space in python query parameters

I have written the following python script, using python requests (http://requests.readthedocs.org/en/latest/): import requests payload = {'key1': 'value 1', 'key2': 'value 2'} headers = {'Content-Type': 'application/json;charset=UTF-8'} r =…
Jesse van Bekkum
  • 1,466
  • 3
  • 15
  • 24
43
votes
3 answers

how to post multiple value with same key in python requests?

requests.post(url, data={'interests':'football','interests':'basketball'}) I tried this, but it is not working. How would I post football and basketball in the interests field?
Jasonyi
  • 501
  • 1
  • 4
  • 10
43
votes
6 answers

How do I clear cache with Python Requests?

Does the requests package of Python cache data by default? For example, import requests resp = requests.get('https://some website') Will the response be cached? If so, how do I clear it?
ethanjyx
  • 1,970
  • 7
  • 28
  • 50
43
votes
7 answers

Python requests arguments/dealing with api pagination

I'm playing around with the Angel List (AL) API and want to pull all jobs in San San Francisco. Since I couldn't find an active Python wrapper for the api (if I make any headway, I think I'd like to make my own), I'm using the requests library. The…
crock1255
  • 1,025
  • 2
  • 12
  • 23
43
votes
3 answers

In what way is grequests asynchronous?

I've been using the python requests library for some time, and recently had a need to make a request asynchronously, meaning I would like to send off the HTTP request, have my main thread continue to execute, and have a callback called when the…
cacois
  • 2,036
  • 2
  • 19
  • 19
42
votes
6 answers

Wait page to load before getting data with requests.get in python 3

I have a page that i need to get the source to use with BS4, but the middle of the page takes 1 second(maybe less) to load the content, and requests.get catches the source of the page before the section loads, how can I wait a second before getting…
ribas
  • 521
  • 1
  • 4
  • 6
42
votes
16 answers

Python module not found even though "Requirement Already satisfied in Pip"

writing some python in OS X, and it's saying several packages I installed with pip "ImportError: no module named requests" When running pip install requests > sudo -H pip install requests Requirement already satisfied: requests in…
zoey cluff
  • 583
  • 2
  • 6
  • 10
42
votes
9 answers

Python requests.exceptions.SSLError: EOF occurred in violation of protocol

I would retrieve some information from an ABB G13 gateway that offer a RESTful JSON API. API is hosted by the gateway via https endpoint. Basic authentication mechanism is used for authentication. However all traffic goes through SSL layers. On…
mzilio
  • 421
  • 1
  • 4
  • 4
42
votes
1 answer

Python requests - Exception Type: ConnectionError - try: except does not work

I am using a webservice to retrieve some data but sometimes the url is not working and my site is not loading. Do you know how I can handle the following exception so there is no problem with the site in case the webservice is not working? Django…
user1431148
  • 727
  • 1
  • 9
  • 21
42
votes
9 answers

Uploading multiple files in a single request using python requests module

The Python requests module provides good documentation on how to upload a single file in a single request: files = {'file': open('report.xls', 'rb')} I tried extending that example by using this code in an attempt to upload multiple files: files…
user462455
  • 12,838
  • 18
  • 65
  • 96