python 2.7 - using variable for urllib url causing unknown url type: '%22http' error -
i trying pass url urllib with:
# file url on each line file_object = open('file.txt', 'r').xreadlines() line in file_object: print line # check if getting correct value var = urllib.urlopen(line).read() i getting error:
ioerror: [errno url error] unknown url type: '%22http' i think %22 means escaped quotation mark.
so url in file formatted as:
"http://www.test.com" and print statement printing out:
"http://www.test.com" and creation of "'s surrounding url generated "\"" + url + "\"" intention urllib being given url in format thought required. seems escape code somehow being kept , urllib not treating value "http://www.test.com".
if putting urls in file quotation marks included, normal not work, quotation marks required literal strings in source code. including quotation marks in file if write in source code "\"http://www.test.com/\"". removing quotation marks file should solve problem.
Comments
Post a Comment