赞
踩
以这个网站为例,爬取美女写真。
代码如下:
- from selenium import webdriver
- from time import sleep
- from lxml import etree
- import requests
- import os
-
- # 浏览器自动化
- headers = {
- "User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) "
- "Chrome/108.0.0.0 Mobile Safari/537.36 Edg/108.0.1462.54 "
- }
- dirName = '0107beautifulgirl' # 新建文件夹
- if not os.path.exists(dirName):
- os.mkdir(dirName)
-
- # 基于浏览器的驱动程序实例化一个浏览器对象
- # 下载谷歌驱动,网址:http://chromediver.storage.googleapis.com/index.html
- bro = webdriver.Chrome(executable_path=r'C:\Program Files\Google\Chrome\Application\chromedriver.exe')
- # 对目的网站发起请求
- bro.get('https://www.yalayi.com/gallery/')
- sleep(1)
- page_list
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。