赞
踩
环境准备:
安装selenium,chromedriver,BeautifulSoup
建议先安装pip,然后可以直接pip来安装很多相关的插件
直接上代码
- import time
- import requests
-
- from selenium import webdriver
- from bs4 import BeautifulSoup
-
- user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"
- headers = {'User-Agent': user_agent}
- chromedriverPath = 'C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe'
- #事先在百度输入框中搜索要下载的图片,取出链接地址。这里搜索的是"证件照"
- httpUrl = "https://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=result&fr=&sf=1&fmq=1526001481384_R&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。