初学爬虫,发现居然有selenium这么个东西,真的神奇噢,可惜性能差.....不过真的好玩哈哈哈
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Key
from scrapy import Selector
#设置选项(可不填)
chrome_options = Options()
chrome_options.add_argument("--disable-gpu")#防bug
#无界面
chrome_options.add_argument("--headless")
#无图
chrome_options.add_argument("blink-settings=imagesEnabled=false")
#访问
browser = webdriver.Chrome(executable_path="webdriver路径直到.exe",chrome_options=chrome_options)
browser.get("url")
sel = Selector(text=browser.page_source)
browser.close()
#点击
click_ele = browser.find_element_by_xpath("")#还可通过find_element_by_id()定位
click_ele.click()
先写这么多,详细内容我去学习一下再做总结!
来源:CSDN
作者:Webmanipulator
链接:https://blog.csdn.net/qq_45709371/article/details/104137622