Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get request python as a string

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

like image 915
Taimoor Khan Avatar asked Sep 30 '15 20:09

Taimoor Khan


People also ask

What is request get in Python?

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.

What is the limitation of get method in Python?

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.


1 Answers

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 
like image 108
kakajan Avatar answered Sep 22 '22 04:09

kakajan