第一步
#src链接要符合下面要求,这里返回是 false or true
def valid_img(src):
return src.endswith('jpg') and 'img.jandan.net' in src
第二步
然后可以把上面的方法,套到find_all 里面用
#获取属性src符合上面规则的 img标签
for img in soup.find_all('img', src=valid_img):
src = img['src']
来源 http://www.testclass.net/crawler/get_images/