1、通过关键词快捷抓取百度图片。
from torchkeras.data import download_baidu_pictures
download_baidu_pictures(keyword='美女',
needed_pics_num=20,
save_dir='women')
2、download_baidu_pictures中用到了一个关键库fake_useragent,用来伪造User-Agent,绕开网站反扒机制。爬虫工作者的福音。
from fake_useragent import UserAgent
headers = {'User-Agent':UserAgent().random}
response = requests.get(url='', headers=headers).content.decode('utf-8')