Use of respond.get - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Use of respond.get (/thread-34443.html) |
Use of respond.get - ebolisa - Jul-31-2021 Hi, I'd like to read the response from a web page by sending this url: "https://mypage.com/get.php?api_key=0123456789". When done from a browser, the link works and I get data from the server. However, when using the following code, I get an error from the web server: "wrong key". I appreciate some insides. TIA # importing the requests library import requests # defining the api-endpoint URL = "https://mypage.com/get.php" # your API key here API_KEY = '0123456789' # data to be sent to api data = {'api_key': API_KEY} # sending post request and saving response as response object r = requests.get(URL) if r: r = requests.get(url = URL, data = data) # extracting response text url_response = r.text print("The response from URL is:%s" % url_response) RE: Use of respond.get - ndc85430 - Jul-31-2021 If you need to send query parameters in the request, then use the params argument to get , not data (docs here: https://docs.python-requests.org/en/latest/api/#requests.request).
RE: Use of respond.get - ebolisa - Jul-31-2021 (Jul-31-2021, 02:08 PM)ndc85430 Wrote: If you need to send query parameters in the request, then use theThank you!! |