【Python爬虫】:模拟登录QQ空间

观察了下QQ空间实在是太好登录了!只需要首先点击账号密码登录,然后输入你的账号和密码就可以了!

 

 

 

其中需要注意的是;

1.进行第一次点击的时候,点击“账号密码”的时候,需要首先切换到iframe模式

2.根据id进行选择输入

代码如下;

from selenium import webdriver
import time
from lxml import etree
from selenium.webdriver.common.action_chains import ActionChains

bro=webdriver.Chrome(executable_path='./driver.exe')
bro.get('https://qzone.qq.com/')

bro.switch_to.frame('login_frame')
a_tag=bro.find_element_by_id('switcher_plogin')
a_tag.click()

username=bro.find_element_by_id('u')
passwd=bro.find_element_by_id('p')

username.send_keys("123456789")
passwd.send_keys("huhuhuhuhuh")

time.sleep(3)

button=bro.find_element_by_id('login_button')
button.click()
#bro.quit()

 

posted @ 2021-02-04 13:28  Geeksongs  阅读(695)  评论(0编辑  收藏  举报

Coded by Geeksongs on Linux

All rights reserved, no one is allowed to pirate or use the document for other purposes.