我正在从 .csv 文件中读取 URL,并尝试解析它们。为什么当我将链接显式放在函数中时,我只能在方案和netlocurlparse(...)
中获得正确的值,看到变量o2
而不是在我让步newsource
时urlparse
?
for line in file:
source = str(line.split(",")[2])
print("ORIGINAL URL: \n" + source)
newsource = source.replace('"',"")
print("REMOVING QUOTES: \n" + newsource)
newsource.strip
print("STRIPPING SPACES: \n" + newsource + "\n")
o = urlparse(newsource)
print("RESULT PARSING: " + str(o) + "\n")
o2 = urlparse("http://nl.aldi.be/aldi_vlees_609.html")
print("RESULT MANUAL PARSING: " + str(o2) + "\n")