Skip to content
Advertisement

Tag: python-requests

Python – Converting urllib to requests

I’m writing code to access the MS365 API and the Python code example uses urllib. I want to instead use requests but I’m not sure how urllib translates into requests as my attempts of doing so have failed. The code example can be found here: https://learn.microsoft.com/en-us/microsoft-365/security/defender-endpoint/run-advanced-query-sample-python?view=o365-worldwide#get-token Answer Modifying @BeRT2me’s answer has made this work.

Parsing a pre tag in html, how to append the indented text to the previous line in Python

Example URL https://bioconductor.org/packages/release/bioc/VIEWS Currently I’m splitting each individual clump of metadata by every blank line, then converting to a dictionary splitting on the first colon using the string before as the key and the string after as the value. THE ISSUE I’m running is that I am going line by line through each package metadata, some lines do not have

Python request.get error on Wikipedia image URL

Requests.get() does not seem to be returning the expected bytes for Wikipedia image URLs, such as https://upload.wikimedia.org/wikipedia/commons/0/05/20100726_Kalamitsi_Beach_Ionian_Sea_Lefkada_island_Greece.jpg: Answer Most websites block requests that come in without a valid browser as a User-Agent. Wikimedia is one such. which will give you expected output

Send in-memory bytes (file) over multipart/form-data POST request. Python

;TLDR I want to send a file with requests.send() using multipart/form-data request without storing the file on a hard drive. Basically, I’m looking for an alternative for open() function for bytes object Hello, I’m currently trying to send multipart/form-data request and pass in-memory files in it, but I can’t figure out how to do that. My app receives images from

Efficiently using the OpenElevation API using Python

I have a large set of latitude/longitude coordinates and would like to get the elevation for each. I want to use the OpenElevation API. According to their API Docs, I can get elevation data through the URL: https://api.open-elevation.com/api/v1/lookup?locations=10,10|20,20|41.161758,-8.583933. As you can see from the example URL, it is possible to get many elevations in a single request (provided you are

Advertisement