資源簡介
代碼片段和文件信息
import?requests
import?re
from?fake_useragent?import?UserAgent
import?ssl
ssl._create_default_https_context?=?ssl._create_unverified_context
def?take_img(realurl):
????headers={
????????‘Referer‘:realurl
????????‘User-Agent‘:UserAgent().randow
????}
????content_=?requests.get(realurlheaders=headers).content
????path=realurl.split(‘/‘)[-1]
????with?open(‘百度圖片/‘+path‘wb‘)as?f:
????????f.write(content_)
????????print(‘圖片{}保存成功,地址在{}‘.format(realurlpath))
def?main():
????????keyword_=?input(‘請輸入需要查詢的關鍵字:‘)
????????depth=int(input(‘請輸入需要爬取的頁數:‘))
????????for?i?in?range(depth):
????????????url=‘https://image.baidu.com/search/index?tn=baiduimage&p
- 上一篇:python病毒(無限鎖屏.py)
- 下一篇:python 飛機大戰
評論
共有 條評論