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
3 answers

Find a dot in a text file and add a newline to the file in Python?

I read from a file, if it finds a ".", it should add a newline "\n" to the text and write it back to the file. I tried this code but still have the problem. inp = open('rawCorpus.txt', 'r') out = open("testFile.text", "w") for line in iter(inp): …
4
votes
1 answer

BadStatusLine Error in using Python, Requests

I use Requests in Python but always encounter BadStatusLine Error. My code is like followings: import requests ip = 'xx.xx.xx.xx' port = 80 proxies={ 'http': 'http://%s:%s'%(ip, port), 'https': 'https://%s:%s'%(ip, port) …
chandler
  • 51
  • 1
  • 5
4
votes
3 answers

How do i send mp3 file with python using telegram bot

How can I send an MP3 audio file to a Telegram Bot using the open-source Python library Requests? I wrote the following code: URL = 'api.telegram.org/bot'+TOKEN+'/sendAudio' af = open("temp.mp3", 'rb') params = {'chat_id' : 421087308, 'audio' :…
ChemBean
  • 63
  • 1
  • 2
  • 5
4
votes
0 answers

Python/Requests returns 401 but same url in browser works as expected

Doing a requests.post with params returns 401 If I print request.url and follow it in a browser it works just fine. The authorization is provided as an api key in an url parameter. I can't figure out why the url would work just fine in the browser…
JerodG
  • 1,248
  • 1
  • 16
  • 34
4
votes
1 answer

How to log AppEnginePlatformWarning as warning not as error

My project uses these python libraries: requests==2.18.4 requests-toolbelt==0.8.0 and calls this at the main.py requests_toolbelt.adapters.appengine.monkeypatch() App engine is logging Error message inside google cloud logs when using the requests…
makkasi
  • 6,328
  • 4
  • 45
  • 60
4
votes
1 answer

python Requests SSL ERROR (certificate verify failed)

I have generated following self-signed certificates for my server and client. I have created ca.crt & ca.key. Using ca.crt & ca.key, I have created server.crt, server.key for server and client.crt, client.key for client respectively. I am using…
nebi
  • 727
  • 3
  • 9
  • 24
4
votes
3 answers

Send Json (contains boolean/numbers) data in python GET(Method) requests

Q. Is it possible to send json data with GET request? I want to pass some filter parameters to read results from DB params = {'is_coming_soon': False, 'is_paid': True, 'limit': 100, 'skip': 0} headers = {'content-type': 'application/json'} response…
OmPrakash
  • 198
  • 1
  • 9
4
votes
3 answers

convert curl to python requests

I'm trying to convert the following curl request to a python requests (using the Requests) curl -X POST -H "Authorization: Bearer " -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "modelId=CommunitySentiment" -F…
Rui Huang
  • 65
  • 2
  • 4
4
votes
1 answer

Getting JSON parameter from requests, I get: 'method' object is not subscriptable

I'm trying to get a parameter from a JSON string loaded with requests. I think I tried any combination I can think of. Any hints are very appreciated. My code is this: r = requests.get(url, headers=headers) json_string = r.json status =…
Kresten
  • 810
  • 13
  • 36
4
votes
1 answer

Requests.get showing different HTML than Chrome's Developer Tool

I am working on a web scraping tool using python (specifically jupyter notebook) that scrapes a few real estate pages and saves the data like price, adress etc. It is working just fine for one of the pages I picked out but when I try to scrape this…
4
votes
1 answer

How can I log in this specific website using Python Requests?

I am trying to log in this website using the following request but it doesn't work The cookie never contains 'userid'. What should I change? Do I need to add headers in my post request? import requests payload = { …
Paul-O
  • 43
  • 5
4
votes
2 answers

Python Requests: Check if Login was successful

I've looked all over the place for the solution I'm looking for but just can't find it. Basically, I'm developing a tool which takes a list of URLs from a text document, logs into them with your username/password, and returns which ones work. I have…
fdev17
  • 41
  • 1
  • 2
4
votes
1 answer

Microsoft Graph API delegated permission

I would like to get my application(python script) be authorized with Graph API on behalf of user. I'm using this document as the reference. Concern: I want to do it in python. Is it possible that I use the requests module and request for an…
4
votes
1 answer

How to add values to built in entities like 'wit$location' in wit.ai

I have tried using API service: response = requests.post('https://api.wit.ai/entities/wit$location/values?v=20160526', headers={'Authorization':'Bearer xxx'}, data=json.dumps({ "value":"London", …
Anubhav Singh
  • 587
  • 2
  • 11
4
votes
1 answer

urllib.request.urlretrieve ERROR trying to download jpeg in Python

I am trying to download a .jpg file, using urllib.request.urlretrieve(url, filename) in Python 3.5.2. The url is http://dm.victoriassecret.com/product/404x539/V603923_CROP1.jpg . The following error raises: http.client.RemoteDisconnected: Remote…
dimosbele
  • 381
  • 3
  • 19