Python Requests – pass parameter via GET [closed]

Here’s the relevant code to perform a GET http call from the official documentation:

import requests
payload = {'key1': 'value1', 'key2': 'value2'}
r = requests.get('http://httpbin.org/get', params=payload)

In order to adapt it to your specific request:

import requests
payload = {'q': 'food'}
r = requests.get('http://httpbin.org/get', params=payload)
print (r.text)

Here’s the obtained result if I run the 2nd example:

python request_test.py
{"args":{"q":"food"},"headers":{"Accept":"*/*","Accept-Encoding":"gzip, deflate","Connection":"close","Host":"httpbin.org","User-Agent":"python-requests/2.18.1"},"origin":"x.y.z.a","url":"http://httpbin.org/get?q=food"}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)