http

why is Python requests not working as intended

why is Python requests not working as intended Question: I want to get some info from an JSON RPC API endpoint. the equivalent curl command is this: curl ‘https://api.mainnet-beta.solana.com’ -X POST -H "Content-Type: application/json" -d ‘ { "jsonrpc": "2.0", "id": 1, "method": "getTokenAccountBalance", "params": [ "FYj69uxq52dee8AyZbRyNgkGbhJdrPT6eqMhosJwaTXB" ] } ‘ it works and response is: {"jsonrpc":"2.0","result":{"context":{"apiVersion":"1.13.5","slot":176510490},"value":{"amount":"68662508944","decimals":5,"uiAmount":686625.08944,"uiAmountString":"686625.08944"}},"id":1} …

Total answers: 1

how to fix response.json() no data available error?

how to fix response.json() no data available error? Question: Earlier today I was trying to web scrape some climate data from here: https://www.weather.gov/wrh/Climate?wfo=sew. I have since found a better way to get the data I need, but I’m still confused about the code issue. I’m new to web scraping but have the following code. The …

Total answers: 1

How to append value of a JSON response in a list (python)?

How to append value of a JSON response in a list (python)? Question: i am getting response from request.post() as this: {‘total’: 3, ‘files’: [{‘fileName’: ‘abc.mp4’, ‘size’: ‘123’}, {‘fileName’: ‘def.mp4’, ‘size’: ‘456’}, {‘fileName’: ‘ghi.mp4’, ‘size’: ‘789’}] } i just want the filename value from this response and store it in an str list. i have …

Total answers: 4

Request headers to scrape pypi.org

Request proxies to access PyPI Question: I am trying to screenscrape PyPI packages using the requests library and beautiful soup – but am met with an indefinite hang. I am able to retrieve html from a number of sites with: session = requests.Session() session.trust_env = False response = session.get("http://google.com") print(response.status_code) i.e. without providing headers. I …

Total answers: 4

S3 User Download Without Local File

S3 User Download Without Local File Question: I am creating a front end web app that connects to Wasabi for S3 storage. I currently have the ability to download a file from my web app, but it requires a local download on the server to send to the user. I am trying to send the …

Total answers: 1

Appending value to a list depending on the JSON response

Appending value to a list depending on the JSON response Question: I’m calling an API and I get the following response: "items": [ { "packagingType": "PCS", "description": "[REDACTED]", "productCode": "MATT", "freightClass": "300", "insuranceValue": 428.70999999971326, "primaryReferenceNumber": null, "poNumber": "[REDACTED]", "skuNumber": "[REDACTED]", "pluNumber": null, "actualQuantity": 1, "actualWeight": 125, "actualWeightUnitOfMeasure": "Pounds", "actualPallets": 1, "actualVolume": null, "actualVolumeUnitOfMeasure": "Cubic Feet", …

Total answers: 2

http server that counts requests

http server that counts requests Question: I am learning to use python to run an HTTP server and wanted to make a server that would count every time I refresh. I tried this: from http.server import HTTPServer, BaseHTTPRequestHandler count = 0 class HelloWorldRequestHandler(BaseHTTPRequestHandler): def do_GET(self): self.send_response(200) self.end_headers() count = count + 1 self.wfile.write(str.encode(count)) httpd = …

Total answers: 1

USPS Package Track API is not returning XML child elements for TrackSummary

USPS Package Track API is not returning XML child elements for TrackSummary Question: Please see the temporary solution at the end. Summary (added 12/24/22 for clarification): USPS’s tracking API is not returning responses in the same format as their documentation. The actual format makes it difficult to extract the event date since there is no …

Total answers: 1

How to properly close an http connection from python requests

How to properly close an http connection from python requests Question: I saw the answers in Closing python requests connection but I don’t think the answers really specify how to close the connection, or maybe I am not really understanding what it does. For example, the following code: import requests with requests.Session() as s: s.post("https://example.com", …

Total answers: 2

how to call http api in roundcube mail client to change password?

how to call http api in roundcube mail client to change password? Question: I wish to call http api to change password in roundcube mail client using python code. How can this be done? Where is the exact location in the roundcube configuration and how is it invoked? Asked By: user956424 || Source Answers: Ensure …

Total answers: 1