Skip to content
Advertisement

Tag: python-requests

Input variable name as raw string into request in python

I am kind of very new to python. I tried to loop through an URL request via python and I want to change one variable each time it loops. My code looks something like this: I want to have the url change at every loop to like url_part1+code+url_part3 and then url_part1+NEXTcode+url_part3. Sadly my request badly formats the string from the

requests.auth.AuthBase TypeError on call

From the docs at https://docs.python-requests.org/en/master/user/authentication/ I gathered that the __call__ function in my own Auth Class should have the r argument, However when i go to call this class in requests.get(auth=MyClass), I get the error TypeError: __call__() missing 1 required positional argument: ‘r’ The code for my class can be found here https://pastebin.com/YDZ2DeaT I’ve tried using the example code, which

Concurrency for requests

I have a python script and I’m sending post requests to same url with different data(different ids). I have to send requests for each id and check them continuously to see if there is a change. I’m handling it with iterating an “ids” list with for loop and sending request for each id and then iterating the list again and

Python requests not redirecting

I’m trying to scrape word definitions, but can’t get python to redirect to the correct page. For example, I’m trying to get the definition for the word ‘agenesia’. When you load that page in a browser with https://www.lexico.com/definition/agenesia, the page which loads is https://www.lexico.com/definition/agenesis, however in Python the page doesn’t redirect and gives a 200 status code This is how

How to parse a list of dictionaries in Python 3

I’m using python(requests) to query an API. The JSON response is list of dictionaries, like below: I’d like to extract 1 field (Identifier) as a list for further analysis (count, min, max, etc.) but I’m having a hard time figuring out how to do this. Answer Python has a syntax feature called “list comprehensions”, and you can do something like:

How to check for what JSON data exists in a Python HTTP Request?

I’m working on a script with Python that will generate a joke using an API I found online. (https://sv443.net/jokeapi/v2/). However, some of the setup/question parts of the joke use JSON Data, which varies between being ‘setup’ and ‘joke’. I’m looking to see if I can write a script that will check which one the response is pulling. I have my

Advertisement