【发布时间】:2020-02-09 05:03:47
【问题描述】:
我想从内容中抓取 img 标签。但问题是一些 img 包含 data-src 和一些包含 src。
我尝试了以下方法:
if(content.find('img',{'itemprop':'contentUrl'})['data-src']):
image=content.find('img',{'itemprop':'contentUrl'})['data-src']
elif(content.find('img',{'itemprop':'contentUrl'})['src']):
image=content.find('img',{'itemprop':'contentUrl'})['src']
仍然无法正常工作,我想抓取包含 data-src 或 src 的所有图像 url。
【问题讨论】:
标签: python beautifulsoup screen-scraping