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
4
votes
0 answers

Python3 SimpleHTTPServer error

I am using SimpleHTTPServer in Python 3.4.3 python -m http.server When I try to do a request from my client scrypt def download_file(url): local_filename = path_leaf(url) try: r = requests.get(url, stream=True, timeout=6) …
Hrvoje T
  • 3,365
  • 4
  • 28
  • 41
4
votes
1 answer

Python, threading, and requests: What happens when I make concurrent requests in one session?

Let's say I make 5 requests via a requests.Session to a server, using a ThreadPoolExecutor: session = requests.Session() executor = concurrent.futures.ThreadPoolExecutor(max_workers=5) def post(data): response =…
right2clicky
  • 785
  • 7
  • 14
4
votes
1 answer

Python - Run multiple get requests in parallel and stop on first response

Python 3.4 requests 2.18 I want to make multiple requests.get calls and return the first that gets a response, stopping the rest. What's the best way to do this? Edit: I ended up using python's multiprocessing module and a queue to achieve the…
4
votes
1 answer

Login website with python requests

I'm trying to login to a webpage using python 3 using requests and lxml. However, after sending a post request to the login page, I can't enter pages that are available after login. What am I missing? import requests from lxml import…
Iglias67
  • 51
  • 3
4
votes
2 answers

Why can't I "ignore" this ConnectionError using a try/except block?

Within my django project I am making a call out to a pull in some data. I have organized the code below so that if the get request fails, it is ignored and the rest of the function continues (please no lectures on if this is bad practice or not). …
david
  • 6,303
  • 16
  • 54
  • 91
4
votes
0 answers

Windows 10 pro and IIS concurrent request limitation

I have developed an c# web application that has an WCF service. This application is hosted in Windows 10 PRO 64x system. Everything works well so far, except from a "concurrent" requests limitation. I performed a stress test via SOAPUI and the IIS…
StDeveloper
  • 55
  • 1
  • 6
4
votes
2 answers

Parsing JSON output efficiently in Python?

The below block of code works however I'm not satisfied that it is very optimal due to my limited understanding of using JSON but I can't seem to figure out a more efficient method. The steam_game_db is like this: { "applist": { "apps":…
Purdy
  • 83
  • 2
  • 7
4
votes
1 answer

Why does requests response object __bool__ check for 200 <= status < 400?

According to the source of the Requests module, the __bool__ function is used solely to check if the status code of a response is between 200 and 400. Returns True if :attr:`status_code` is less than 400. This attribute checks if the status code of…
jarcobi889
  • 815
  • 5
  • 16
4
votes
1 answer

How to handle HTTP Status Codes across a Python application?

I'm trying to standardize my handling of HTTP status codes returned from various APIs in an effort to reduce the amount of code I copy across files. For my current application, I have a set of files that each contain one class that all derive…
Bianchi
  • 138
  • 1
  • 2
  • 7
4
votes
1 answer

Selenium and BeautifulSoup: sharing and pulling session data resources to multiple libraries in python

I have problems comparing two libraries in Python 3.6. I use Selenium Firefox WebDriver to log into a website, but when I want BeautifulSoup or Requests to read that website, it reads the link, but differently (reads that page as if I have not…
4
votes
1 answer

Cannot locate the Microsoft Visual FoxPro support library

I have recently updated the Requests package for Python (I also installed WireShark around the same time, but I'm not sure if that's relevant). Since doing this, whenever I try and execute a Python file from the command line that imports the…
Mr. Pickles
  • 89
  • 1
  • 3
  • 7
4
votes
2 answers

Python - requests fail silently

import requests is working properly for all my requests, like so: url = 'http://www.stackoverflow.com' response = requests.get(url) bur the following url does not return any results: url = 'http://www.billboard.com' response =…
8-Bit Borges
  • 9,643
  • 29
  • 101
  • 198
4
votes
1 answer

What are the drawbacks for making the connection pool size for the Python 'requests' module very large?

In mounting an HTTPAdapter onto a requests.Session() I came into an issue where connections eventually were discarded because I was issuing async calls (for the same host, i.e. belonging to the same connection pool) in batches where each batch size…
4
votes
2 answers

requests.get in python giving connection timeout error

Language Ver: Python 3.6.3 IDE Ver: PyCharm 2017.2.3 I was trying to parse a weather website to print weather for a place. As I am learning Python, previously I used urllib.request.urlopen(url).read() and it worked. Now, I am modifying the code to…
4
votes
1 answer

Get Oauth Access Token in Python

I am trying to generate a oauth access token for experian's sandbox API (they give information on credit information). Their tutorial Says to run this (fake data) to get an access token: curl -X POST -d '{ "username":"youremail@email.com",…
user123
  • 208
  • 2
  • 8