Home urlopen error while updating url with variable
Reply: 1

urlopen error while updating url with variable

user3198755
1#
user3198755 Published in 2017-11-12 16:53:41Z

I am trying to update the url with keywords from another file and read the contents of the url but it is throwing error

f = open('myfile.txt')
for line in iter(f):
    id = line.strip('\n')
    url_sell = 'https://example.com/getmarketsummary?market='+str(id)
    df = pd.read_json(url_sell, orient='columns')

Below is the error

urllib2.URLError: <urlopen error no host given>
EM28
2#
EM28 Reply to 2017-11-12 17:16:43Z

Use try, excep to debug.

for line in iter(f):
    id = line.strip('\n')
    try:
        url_sell = 'https://example.com/getmarketsummary?market='+str(id)
    except:
        return id
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.397468 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO