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

Trouble using python request module to make API post call within AWS lambda

After connecting to the requisite AWS resources at the beginning of my lambda execution function, I have a lambda_handler function that looks like the following: def lambda_handler(event, context, dst): bucket =…
aaron
  • 6,339
  • 12
  • 54
  • 80
4
votes
1 answer

Python Requests: Logging into website using POST and Cookies

I tried searching for couple of hours, but nothing seem to be working. I am trying to login to a webpage to download some data. Each login requires a new cookie (PHPSESSID) since it expires when browsing connection ends. I tried the…
onepint16oz
  • 294
  • 3
  • 12
4
votes
2 answers

Missing certain part of Cookies using requests.get()?

BackgroundInfo: I am scraping amazon. I need to set up the session cookies before using requests.session.get() to get the final version of the page source code of a url. Code: import requests # I am currently working in China, so it's cn. # Use…
Sam Chan
  • 510
  • 1
  • 8
  • 20
4
votes
1 answer

Converting JSON object from requests.get() to dict

I'm pulling a json object from a url: import requests r = requests.get('http://my.endpoint.com/Hardware.json') Now I need to convert this from r.json() to a dict, so that I can insert it as a document to MongoDB (I think. I'm new to Mongo, soo).…
MrDuk
  • 16,578
  • 18
  • 74
  • 133
4
votes
1 answer

json object returned by http response

I am using python and django to develop some REST APIs. I have a question about the JSON unicode string returned by the requests call. So, I am doing something like: resp = requests.get(self.url) if resp.status_code is status.HTTP_200_OK: obj =…
Luca
  • 10,458
  • 24
  • 107
  • 234
4
votes
1 answer

Is there a way to get response headers without download the url content in Python?

I'm using Python to write a manager that will download some files given some conditions. The problem is that the conditions are to be performed against the response headers. The example below is a simplified version of what I'm doing now. I first…
srodriguex
  • 2,900
  • 3
  • 18
  • 28
4
votes
2 answers

website visit using python requests doesn't count in google analytics

website visit using python requests doesn't count in google analytics real time I am using python requests module and google counts the visit but not found in google analytics real time (active users) my code is below: import requests import…
Mohamed Yousof
  • 725
  • 1
  • 9
  • 38
4
votes
1 answer

Unexpected response with Google Safe Browsing API v4 and Python requests

I'm trying to implement a small function to verify possible phishing URL's and thought that using Google Safe Browsing API would be a good start. After reading the API documentation I thought I had a handle on things and cobbled together the…
Swedish Mike
  • 583
  • 1
  • 8
  • 23
4
votes
4 answers

Python requests: URL with percent character

I have been searching all over the place for this, but I couldn't solve my issue. I am using a local API to fetch some data, in that API, the wildcard is the percent character %. The URL is like so : urlReq =…
Elie
  • 337
  • 3
  • 6
  • 14
4
votes
2 answers

How to download a file from an url and keep its name and metadata with python requests

In the browser if I click on a download button, a file will be downloaded with its original name and metadata. Currently I can download a file with python requests, but I have to give it a name and none of the metadata is available with the…
raitisd
  • 3,875
  • 5
  • 26
  • 37
4
votes
2 answers

How to Catch a 503 Error and retry request

I'm using grequests to make about 10,000 calls, but some of these calls return as 503. This problem goes away if I don't queue all 10,000 calls at once. Breaking it into groups of 1000 seems to do the trick. However I was wondering if there's a way…
Rafael
  • 3,096
  • 1
  • 23
  • 61
4
votes
1 answer

Unable to POST to Grafana using Python3 module requests

I'm trying to create a dashboard on Grafana using their backend API. I first test that my API token is set up by using GET and successfully get a return code of 200(shown below). I then try to use POST to create a simple dashboard but I keep getting…
student_123
  • 47
  • 1
  • 5
4
votes
2 answers

How to do POST using requests module with Flask server?

I am having trouble uploading a file to my Flask server using the Requests module for Python. import os from flask import Flask, request, redirect, url_for from werkzeug import secure_filename UPLOAD_FOLDER = '/Upload/' app =…
Duggy
  • 75
  • 2
  • 6
4
votes
3 answers

Why is Python logging framework losing messages?

I have a Python 3.4 application that uses logging extensively. I have two FileHandlers and a StreamHandler registered. Everything works as expected except that sometimes, and it seems to happen after the requests library throws an exception, the log…
4
votes
2 answers

Convert CURL Post to Python Requests Failing

I am unable to successfully convert and execute a curl post command to python code. curl command curl -X POST -H "Content-Type:application/json; charset=UTF-8" -d '{"name":joe, "type":22, "summary":"Test"}' http://url Converted code import…
Le Ray
  • 367
  • 2
  • 12