我正在寻找一个值“未找到”,但我的代码没有找到它。相反,如果该值未找到,它只会崩溃
这是代码
for key, value in productLinks.iteritems():
if value is "Not Found":
print value
else:
print value
html = urllib2.urlopen(value)
soup = BS(html)
foundPrice = soup.find('s')
if found is not None:
print "found a price"
else:
print" No Lunk"
这是错误
Traceback (most recent call last):
File "asimsScrapper.py", line 28, in <module>
html = urllib2.urlopen(value)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 386, in open
protocol = req.get_type()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 248, in get_type
raise ValueError, "unknown url type: %s" % self.__original
ValueError: unknown url type: Not found