I wanted to send a get request in python and return it as a string. I wanna eventually use that string as something later on. Also by default does python return it in json format?
req = requests.get(server, auth=('user',"pass"))
thanks
Python's requests module provides in-built method called get() for making a GET request to a specified URL. Syntax – requests.get(url, params={key: value}, args) Example – Let's try making a request to Github's APIs for example purposes.
The GET method has size limitation: only 1024 characters can be sent in a request string. The GET method sends information using QUERY_STRING header and will be accessible in your CGI Program through QUERY_STRING environment variable.
Use python requests. Check the link, there are examples how you get json from response.
req = requests.get(server, auth=('user',"pass")) req.json()
If you want it as string, use
req.text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With