1. 程式人生 > >爬蟲11-知乎

爬蟲11-知乎

from selenium import webdriver
import time
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://www.zhihu.com/explore')
driver.find_element_by_link_text("登入").click()
username = input('輸入知乎賬號:')
pwd = input('輸入知乎密碼:')
driver.find_element_by_name('username').send_keys(username)
driver.find_element_by_name('password').send_keys(pwd)
driver.find_element_by_xpath('//*[@id="root"]/div/main/div/div/div/div[2]/div[1]/form/button').click()
print(driver.page_source)
time.sleep(3)
print('Success')
driver.quit()