I am brand new to Python coding, and getting stuck with a particular task.
I have the following URL: https://freeman7.zendesk.com/api/v2/views/313117127/count.json
I would like to use Python to display something like the following (this is the content that that URL displays when you open it in a web browser):
{
"view_count": {
"url": "https://freeman7.zendesk.com/api/v2/views/313117127/count.json",
"view_id": 313117127,
"value": 2,
"pretty": "2",
"fresh": true
}
}
I've tried all sorts of things after searching the Internet for a couple of hours, but can't seem to find anything that works. Here is an example of something I've tried:
import urllib.request, json
with urllib.request.urlopen("url") as url:
data = json.loads(url.read().decode())
print(data)
And here is the error I get for that:
URLError: urlopen error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
Anyone have any idea what's going on here, and/or have a recommendation on how I could successfully complete this task? I would appreciate any insight!
Thanks, Stephen
urllib.requestsSessionobject to post proper credentials on the login page, then use the sameSessionobject to make the API call. You wil have to read some doumentation ;)