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
31
votes
1 answer

Custom JSONEncoder for requests.post

I'm writing wrapper for REST API and use requests module. Method .json() of Response object transfers **kwargs to json.loads() function, so I can easily use custom JSON decoder and, i. e. transparently convert UNIX epoch timestamps to…
31
votes
4 answers

How can I set a single proxy for a requests session object?

I'm using the Python requests package to send http requests. I want to add a single proxy to the requests session object. eg. session = requests.Session() session.proxies = {...} # Here I want to add a single proxy Currently I am looping through a…
Torra
  • 1,182
  • 5
  • 15
  • 23
30
votes
2 answers

Python - Json List to Pandas Dataframe

I've a json list and I can't convert to Pandas dataframe (various rows and 19 columns) Link to response : https://www.byma.com.ar/wp-admin/admin-ajax.php?action=get_historico_simbolo&simbolo=INAG&fecha=01-02-2018 json response: [ …
30
votes
4 answers

What's the meaning of pool_connections in requests.adapters.HTTPAdapter?

When initializing a requests' Session, two HTTPAdapter will be created and mount to http and https. This is how HTTPAdapter is defined: class requests.adapters.HTTPAdapter(pool_connections=10, pool_maxsize=10, …
laike9m
  • 18,344
  • 20
  • 107
  • 140
30
votes
1 answer

Is it possible to "transfer" a session between selenium.webdriver and requests.session

In theory, if I copy all of the cookies from selenium's webdriver object to requests.Session object, would requests be able to continue on as if the session was not interrupted? Specifically, I am interested in writing automation where I get to…
Goro
  • 9,919
  • 22
  • 74
  • 108
30
votes
2 answers

Python Requests POST doing a GET?

I am using Python 2.7.5, Django 1.7, requests 2.4.1, and doing some simple testing. However, it seems like when I call requests.post, the method is doing a GET instead. My code, talking to a RESTful API. Note that the POST command works via Hurl.it…
user
  • 4,651
  • 5
  • 32
  • 60
30
votes
2 answers

How to include third party Python packages in Sublime Text 2 plugins

I'm writing a sublime text 2 plugin that uses a module SEAPI.py which in itself imports the requests module. Since sublime text 2 uses it's own embedded python interpreter, it doesn't see the requests module installed in my ubuntu machine (I get the…
29
votes
3 answers

Python Requests with wincertstore

I'm trying to connect to my corporate's internal webpages through the requests package, but since python does not use the windows default trusted certificates the connection is denied. I found out that wincertstore can be used to fetch the windows…
adimessi30
  • 415
  • 1
  • 4
  • 9
29
votes
8 answers

Using Python decorators to retry request

I have multiple functions in my script which does a REST API api requests.As i need to handle the error scenarios i have put a retry mechanism as below. no_of_retries = 3 def check_status(): for i in range(0,no_of_retries): url =…
PGS
  • 1,046
  • 2
  • 17
  • 38
29
votes
3 answers

unable to decode Python web request

I am trying to make web request to my trading account . Python is unable to decode the web request. Web request is successful with code - 200. Here is the code below import requests headers = { 'accept-encoding': 'gzip, deflate, br', …
dnyanesh ambhore
  • 441
  • 1
  • 4
  • 8
29
votes
6 answers

Python requests isn't giving me the same HTML as my browser is

I am grabbing a Wikia page using Python requests. There's a problem, though: the requests request isn't giving me the same HTML as my browser is with the very same page. For comparison, here's the page Firefox gets me, and here's the page requests…
obskyr
  • 1,380
  • 1
  • 9
  • 25
29
votes
2 answers

Cannot import requests.packages.urllib3.util 'Retry'

I am using Python 2.7 64 bit on Windows 8. I have Requests version 2.3 installed. I am trying to run this import statement as part of bringing in number of retries within my code: from requests.packages.urllib3.util import Retry I have urllib3…
gdogg371
  • 3,879
  • 14
  • 63
  • 107
29
votes
2 answers

How to simulate HTTP post request using Python Requests module?

This is the module that I'm trying to use and there is a form I'm trying to fill automatically. The reason I'd like to use Requests over Mechanize is because with Mechanize, I have to load the login page first before I can fill it out and submit,…
Display Name
  • 947
  • 2
  • 10
  • 18
28
votes
1 answer

is "from flask import request" identical to "import requests"?

In other words, is the flask request class identical to the requests library? I consulted: http://flask.pocoo.org/docs/0.11/api/ http://docs.python-requests.org/en/master/ but cannot tell for sure. I see code examples where people seem to use them…
Fred Zimmerman
  • 1,178
  • 3
  • 13
  • 29
28
votes
3 answers

Python Requests: requests.exceptions.TooManyRedirects: Exceeded 30 redirects

I was trying to crawl this page using python-requests library import requests from lxml import etree,html url = 'http://www.amazon.in/b/ref=sa_menu_mobile_elec_all?ie=UTF8&node=976419031' r = requests.get(url) tree = etree.HTML(r.text) print…
user3628682
  • 685
  • 1
  • 11
  • 19