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

Python: async requests with grequests not significantly faster than requests

I am just getting started in learning how to using the requests module in Python to fetch data from an API. I will be calling to this API using a very simple GET request, but I will need to do it 500,000+ times, only passing a different value for…
CurtLH
  • 2,329
  • 4
  • 41
  • 64
4
votes
2 answers

urlopen/requests.get not working in threads created in imported modules

I have a problem with urlopen (and requests.get) In my program, if I run it inside a thread (I tested with multiprocessing too) [update: a thread that has been created by an imported module] it won't run until the program ends. By "won't run" I mean…
René
  • 179
  • 8
4
votes
1 answer

How to create a user in the Moodle Rest WS using the Python Requests module?

I'm trying to create a user using the Moodle Webservices - Rest Server, but I'm stuck at the validation of the params :S My code is the following: import requests token = 'TOKENNUMBER' function = 'core_user_create_users' url =…
arthas_dk
  • 443
  • 5
  • 15
4
votes
1 answer

Python requests: load SSL certificate from database

I am using requests to consume a web service in https protocol. I used to verify the server certificate by setting verify as the file path to the certificate. But now I want to store the server certificate to the database. At the runtime, the…
ichbinblau
  • 4,507
  • 5
  • 23
  • 36
4
votes
2 answers

Python Request What is the proper way to modify the value of an existing cookie?

I am accessing a webpage which creates a cookie with a value, and then modify this value and access another page from the same website. Using librequests in python I got the following cookie: s is a session opened with s = requests.Session() In…
aze
  • 832
  • 4
  • 12
  • 34
4
votes
2 answers

BeautifulSoup output to .txt file

I am trying to export my data as a .txt file from bs4 import BeautifulSoup import requests import os import os os.getcwd() '/home/folder' os.mkdir("Probeersel6") os.chdir("Probeersel6") os.getcwd() '/home/Desktop/folder' os.mkdir("img") #now…
Danisk
  • 113
  • 1
  • 1
  • 9
4
votes
1 answer

Most efficient way to check if a session is still valid/handle connectionError?

How can I check if a Session in Python 3.5 will still be able to handle get() requests? Is there a standard procedure that people use to check for this when sending get() requests with a Session when they reuse the same Session for multiple…
geofurb
  • 489
  • 4
  • 13
4
votes
0 answers

How to use grequests in flask?

I am experimenting with gunicorn with gevent workers and Flask. In a view function, I need to make a GET request to an url. Previously, I'm using requests library to do that. But since I want to use gevent workers, I believe I have to make it async,…
hans-t
  • 3,093
  • 8
  • 33
  • 39
4
votes
1 answer

How to click submit button in a form?

I am trying to scrap this website for fund price history, by providing the start date, end date and click the 'Get Prices' button via POST method. However the page requests.post() return does not contain the results, as if the "Get Price" button was…
vkc
  • 556
  • 2
  • 8
  • 18
4
votes
1 answer

How to get the server info of a website using python requests?

I want to make a web crawler to make a statistic about most popular server software among Bulgarian sites, such as Apache, nginx, etc. Here is what I came up with: import requests r = requests.get('http://start.bg') print(r.headers) Which return…
Boyan Kushlev
  • 1,043
  • 1
  • 18
  • 35
4
votes
1 answer

Uploading attachments to Confluence REST API with Python Requests gives 415 and 500 Errors

I am trying to upload an attachment to Confluence via the REST API, using Python Requests. I always get either a "415 unsupported media type" error or a "500 internal server error", depending on how I send the request. There are several bits of…
Arne Mertz
  • 24,171
  • 3
  • 51
  • 90
4
votes
2 answers

How to send HTTP request in SSH?

I'm trying to make a simple HTTP request in Python in an SSH terminal: from requests import get r = get("https://www.google.com") However, this command just stalls to infinity. This does not happen when not in SSH. Is there any way to send the…
Cisplatin
  • 2,860
  • 3
  • 36
  • 56
4
votes
1 answer

Is urllib2 slower than requests in python3

I use python to simply call api.github.gist. I have tried urllib2 at first which cost me about 10 seconds!. The requests takes less than 1 senond I am under a cooperation network, using a proxy. Do these two libs have different default behavior…
templefox
  • 475
  • 1
  • 5
  • 17
4
votes
1 answer

Python requests, multipart without files

Is it possible to send a multipart/form-data with python requests without sending a file? My requests header should look like this: --3eeaadbfda0441b8be821bbed2962e4d Content-Disposition: form-data;…
user5270337
4
votes
1 answer

Python requests package returning different HTTP status than browser

I am using the following code: import requests url = 'http://www.transfermarkt.com/' r = requests.get(url) r.raise_for_status() And I have the following output: HTTPError: 404 Client Error: Not Found for url: http://www.transfermarkt.com/ But the…
Mpizos Dimitris
  • 4,819
  • 12
  • 58
  • 100
1 2 3
99
100