Jul-31-2021, 02:06 PM
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
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)