python爬虫学习-day7

丁香园大作战

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from selenium import webdriver
import time

bs = webdriver.Chrome()
bs.get("http://www.dxy.cn")

time.sleep(2)

bs.find_element_by_link_text('登录').click()
bs.find_element_by_link_text('返回电脑登录').click()
user = bs.find_element_by_name('username').send_keys('dxy_lfrcym19')
password = bs.find_element_by_name('password').send_keys('daisiming830')

print('登录')
bs.find_element_by_xpath('//button').click()

time.sleep(10)
print('获取信息')
elems = bs.find_element_by_css_selector(".auth")
for elem in elems:
auth = elem.find_element_by_tag_name("a")
print(auth_text)

没能完成,只能占坑了。我要去复习了,再见!