python - When using urllib2, getting HTTPError 404 -


so i'm using following code:

allargs = ['subway.py', '1b8d465e-b217-46f9-87a7-e9e48aaccb0f', 'b38']  httpcookieprocessor()  bus = urllib2.urlopen("http://api.prod.obanyc.com/api/siri/ \     vehicle-monitoring.json?key=" + allargs[1] + \     "&vehiclemonitoringdetaillevel=calls&lineref=" + allargs[2]) 

and getting httperror 404. tried reading other documentation , questions on various forums error, can't understand it. answering similar question mentioned making cookie opener, again don't understand means. tried looking @ examples of other people making cookie openers, seemed involve lot of things don't appear relevant i'm trying here, , i'm not sure need.

help appreciated, thank you.

try instead:

import urllib import json  url = "http://api.prod.obanyc.com/api/siri/vehicle-monitoring.json?"  args = {'vehiclemonitoringdetaillevel': 'calls'} args['key'] = '1b8d465e-b217-46f9-87a7-e9e48aaccb0f' args['lineref'] = 'b38'  try:     data = json.load(urllib.urlopen('{}{}'.format(url, urllib.urlencode(args)))) except (ioerror, valueerror):     print('problem fetching data') 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -