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

Using urllib to get the final redirect of a webpage in Python 3.5

As in this post, I attempt to get the final redirect of a webpage as: import urllib.request response = urllib.request.urlopen(url) response.geturl() But this doesn't work as I get the "HTTPError: HTTP Error 300: Multiple Choices" error when…
Ólavur
  • 410
  • 4
  • 15
4
votes
1 answer

requests.exceptions.SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)

I am trying to access a website with the requests package like this page = requests.get('https://jobregister.aas.org') but I get the following Traceback (most recent call last): File "daily.py", line 453, in main() File…
carl
  • 4,216
  • 9
  • 55
  • 103
4
votes
1 answer

python post request with certificate

how to send certificate authentication in python post request, for example I used next but in get request: requests.get(url, params = params, timeout=60,cert=certs) where certs is path to certificate, it's worked…
MR.A
  • 41
  • 2
  • 6
4
votes
2 answers

Python Requests throws SSL Error on certain site

EDIT - FIXED tldr, semi-old version of python installed a couple years ago had ssl package that was not updated to handle newer SSL certificates. After updating Python and making sure the ssl package was up to date, everything worked. I'm new to…
spaderdabomb
  • 942
  • 12
  • 28
4
votes
1 answer

Creating a function using yield instead of return to generate frames from an http stream continuously

I would like to create a function that reads frames from an HTTP stream using requests and returns each frame. But because of the fact that the stream reader is based on an iterator object (if I understand correctly), returning a frame is breaking…
Michał Gacka
  • 2,935
  • 2
  • 29
  • 45
4
votes
2 answers

Using 'Requests' python module for POST request, receiving response as if it were GET

So I am trying to make a script that checks a reservation availability of a bus. The starting link for this is https://reservation.pc.gc.ca/. In the reserve box the following needs to be selected: Reservation: Day Use (Guided Hikes, Lake O’Hara…
Tennyx
  • 153
  • 10
4
votes
0 answers

How to use Python requests to simultaneously download and upload a file

I'm trying to stream a download from an nginx server and simultaneously upload it. The download is using requests stream implementation; the upload is using chunking - the intention is to be able to report progress as the down/upload is…
otupman
  • 1,238
  • 10
  • 20
4
votes
1 answer

Robot framework pass cookie to get request (RequestsLibrary) - TypeError

I need to pass cookie value to Get request keyword to make it work, but it is still failing. I am not sure how to pass it correctly there. Documentation of the keyword says about the headers: "headers: a dictionary of headers to use with the…
neliCZka
  • 945
  • 1
  • 16
  • 27
4
votes
2 answers

Requests Library Force Use of HTTP/1.1 On HTTPS Proxy CONNECT

I am having a problem with a misbehaving HTTP Proxy server. I have no control over the proxy server, unfortunately -- it's an 'enterprise' product from IBM. The proxy server is part of a service virtualization solution being leveraged for software…
Keozon
  • 998
  • 10
  • 25
4
votes
1 answer

Python Requests Refresh

I'm trying to use python's requests library to log in to a website. It's a pretty simple code, and you can really get the gist of requests just by going on its website. I, however, want to check if I'm successfully logged in via the url. The problem…
revanchist
  • 63
  • 1
  • 1
  • 4
4
votes
1 answer

python requests return a different web page from browser or urllib

I use requests to scrape webpage for some content. When I use import requests requests.get('example.org') I get a different page from the one I get when I use my broswer or using import urllib.request urllib.request.urlopen('example.org') I…
Mohamed El-Saka
  • 732
  • 10
  • 13
4
votes
1 answer

Can InsecureRequestWarnings be disabled in the requests module?

This post explains how to disable the warnings in urllib3, but I'm using a session object with the requests module. The warnings are occurring because the verify (ssl) parameter is set to False in order to access a page. e.g. url =…
ballade4op52
  • 2,142
  • 5
  • 27
  • 42
4
votes
1 answer

Giving error "the JSON object must be str, not 'bytes' "

I was following a tutorial that how to use elasticsearch with python (link= https://tryolabs.com/blog/2015/02/17/python-elasticsearch-first-steps/#contacto) i faced this error. import json r = requests.get('http://localhost:9200') i…
Taimour Ali
  • 96
  • 2
  • 5
4
votes
1 answer

How to upload a pdf by sending a POST Request to an API

I have tried to upload a pdf by sending a POST Request to an API in R and in Python but I am not having a lot of success. Here is my code in R library(httr) url <- "https://envoc-apply-api.azurewebsites.net/api/apply" POST(url, body =…
Dre
  • 713
  • 1
  • 8
  • 27
4
votes
1 answer

Is it possible to catch all exceptions for requests? (and generally, for a module)

I have some code which will make a requests.get() call, which may fail in various ways. I want to catch requests exceptions, but do not care about why the call failed. I would like to avoid code like try: r = requests.get(url) except: …
WoJ
  • 27,165
  • 48
  • 180
  • 345