Skip to content
Advertisement

Tag: python-requests

What is the easiest way to get the url a link redirects to?

I have a number of urls that redirect to other ones and I would like to find the address of the links they redirect to. For example, https://stlouisfed.org/fomcspeak/thomas-barkin/2019/04/apr-speech-a-practitioners-perspective-on-the-productivity-slowdown redirects to https://www.richmondfed.org/press_room/speeches/thomas_i_barkin/2019/barkin_speech_20190404 I tried using the requests library like so: But I’m running getting the error below. Any idea what might be going wrong? Answer I reproduced your issue with the

Pythons requests library removing appending question mark from URL

Goal Make request to http://example.com/page? using requests.get() Problem The question mark (“?”) is automatically stripped from the request if it is the last character in the URL (eg. http://example.com/page?1 and http://example.com/page?! work, http://example.com/page? does not) Sample code Question Without modifying the library, is it possible to reach the intended endpoint? Both intended solutions (if such exist) and workarounds are welcome.

response.text is printing only special symbols for a plain-text response

A GET request downloads following output (checked the response with Chrome Dev Tools): HTML output Output via response.content When I am printing response.content to the console or to a file I am getting something like this: Output via response.text With response.text I got this (as depicted in image): Original Code All variables are already defined: How can the plain-text response

changing ampersands to %26

I am using Python-requests to pull data from a website. I am doing this currently : which gives me: https://someurl?query=&A=something&B=something This is all perfectly fine and great. However, the website doesn’t accept my API call. After some meddling around, I discovered that my target url is actually this: https://someurl?query=%26A=something%26B=something Hence my question : Is there a workaround for this problem?

Python multi connection downloader resuming after pausing makes download run endlessly

I have written a Python script that downloads a single file using 32 connections if available. I have written a multiconnection downloader that works fine without pausing, but won’t stop downloading after resuming, the progress would go beyond 100%… Like this: After progress exceeds 100%, there will be error messages like this: (The above doesn’t include all of the error

Advertisement