request

How to handle API response in python

How to handle API response in python Question: I wonder how I can properly handle this invalid response. How to check if the response has status: 400 or perhaps has a title: Bad Request? url = f"https://api123.com" substring = "title: Bad Request" response = requests.get(url, headers=headers).json() if substring in response: print ("Your Data is Invalid") …

Total answers: 2

How to use two APIs to get the response of an endpoint once it processed?

How to use two APIs to get the response of an endpoint once it processed? Question: I have two APIs: triggerAPI and triggerAPIResult. When I hit the first one, it would trigger a process which could take a few minutes to return the response. The second API is used to check if the process is …

Total answers: 1

How to read a webpage table using requests-html?

How to read a webpage table using requests-html? Question: I am new to python and am trying to parse a table from the given website into a PANDAS DATAFRAME. I am using modules requests-html, requests, and beautifulSoup. Here is the website, I would like to gather the table from: https://www.aamc.org/data-reports/workforce/interactive-data/active-physicians-largest-specialties-2019 MWE import pandas as pd …

Total answers: 1

Getting code from a .txt on a website and pasting it in a tempfile PYTHON

Getting code from a .txt on a website and pasting it in a tempfile PYTHON Question: I was trying to make a script that gets a .txt from a websites, pastes the code into a python executable temp file but its not working. Here is the code: from urllib.request import urlopen as urlopen import os …

Total answers: 2

can't get page source from selenium

can't get page source from selenium Question: purpose: using selenium get entire page source. problem: loaded page does not contain content, only JavaScript files and css files. target site : https://www.warcraftlogs.com test code(need ‘pip install selenium’): from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.warcraftlogs.com/zone/rankings/29#boss=2512&metric=hps&difficulty=3&class=Priest&spec=Discipline") pageSource = driver.page_source fileToWrite = open("page_source.html", "w",encoding=’utf-8′) fileToWrite.write(pageSource) fileToWrite.close() trythings– try …

Total answers: 1

Python Max retries exceeded with url while using request

Python Max retries exceeded with url while using request Question: I was working on urls using request library. so I can check that if the URL is working or not using get method. The Script works fine for the rest of URLs but for one url it took a lot of time and then this …

Total answers: 1

How can I get all data from JSON using JMESPath

How can I get all data from JSON using JMESPath Question: I am trying to get all the data with the attribute _name equal to accountId. I have managed to do it almost fine, the only issue is that from times to times times I have an object. with two _name attributes with the value …

Total answers: 1

Problems on post method with form and tuple data

Problems on post method with form and tuple data Question: I’m trying to make a post request to this url: url I’m trying this code to get this request: from requests import get, post data = { ‘entrada’: { ‘site’: ‘site’, ‘origen’: ‘origen’, ‘tipo’: ‘turismo’, ‘fecha’: 2022, ‘marca’: -1, ‘marcanombre’: ”, ‘modelo’: -1, ‘modelonombre’: ”, …

Total answers: 1

Why is 'https://revoked.badssl.com/' and 'https://pinning-test.badssl.com/' returning 200 response using Python requests?

Why is 'https://revoked.badssl.com/' and 'https://pinning-test.badssl.com/' returning 200 response using Python requests? Question: I’m working with Python requests and testing URLs from https://badssl.com/ certificate section and all the invalid URLs are returning errors except for https://revoked.badssl.com/ and https://pinning-test.badssl.com/. They are responding with 200 status codes. I would like someone to explain why this is happening, despite …

Total answers: 1

Creating function to call api for pagination is calling duplicate value int

Creating function to call api for pagination is calling duplicate value int Question: I am building a simple app in react and django in which I am accessing API and paginating in the backend. The Problem is that, I want to make two calls on per page click, for example – If user clicked on …

Total answers: 2