【爬虫】selenium动态页面请求与模拟登录知乎
一。安装selenium pip install selenium 二。安装相应浏览器的Driver(selenium 文档) http://selenium-python.readthedocs.io/api.html 推荐使用Chrome 三。selenium的使用 1 # -*- coding: utf-8 -*- 2 3 from selenium import webdriver 4 from scrapy.selector import Selector 5 6 7 # 知乎的模拟登录 8 browser = webdriver.Chrome(executable_path= " E:/chromedriver.exe " ) # 路径是chromedriver.exe的存放的位置 9 browser.get( " https://www.zhihu.com/#signin " ) 10 browser.find_element_by_css_selector( " .view-signin input[name='account'] " ).send_keys( " ******** " ) # 帐号 11 browser.find_element_by_css_selector( " .view-signin input[name='password'] " )