for imgsrc in Soup.findAll('img', {'class': 'sizedProdImage'}):
if imgsrc:
imgsrc = imgsrc
else:
imgsrc = "ERROR"
patImgSrc = re.compile('src="(.*)".*/>')
findPatImgSrc = re.findall(patImgSrc, imgsrc)
print findPatImgSrc
'''
<img height="72" name="proimg" id="image" class="sizedProdImage" src="http://imagelocation" />
这是我想从提取和我得到:的Python 2.7美丽的汤IMG SRC提取
findimgsrcPat = re.findall(imgsrcPat, imgsrc)
File "C:\Python27\lib\re.py", line 177, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or buffer
''”
仍然得到错误: 回溯(最近通话最后一个): 文件 “C:\用户\ BuyzDirect \桌面\ OverStock_Listing_Format_Tool.py” 50行,在 findPatImgSrc = patImgSrc .findall(imgsrc) TypeError:预期的字符串或缓冲区 –
phales15