当前位置:网站首页>CSDN auto sign in
CSDN auto sign in
2022-06-24 01:11:00 【ruochen】
#csdn Automatic check in
csdn Automatic check-in applet
One 、python+selenium Development
by Tansty
github Address :
gitte Address :
1. The login page
(1) First enter the official website
<img src="https://img-blog.csdnimg.cn/20200818163240304.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3RhbnN0eV96aA==,size_16,color_FFFFFF,t_70#pic_center" alt=" Insert picture description here "> (2) Click login <img src="https://img-blog.csdnimg.cn/20200818163307974.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3RhbnN0eV96aA==,size_16,color_FFFFFF,t_70#pic_center" alt=" Insert picture description here ">
2. Log in
(1) First, you need to click the account and password to log in <img src="https://img-blog.csdnimg.cn/20200818163411610.png#pic_center" alt=" Insert picture description here ">
Construct statements to find elements
driver.find_element_by_link_text(" Account password login ").click()<img src="https://img-blog.csdnimg.cn/20200818163506754.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3RhbnN0eV96aA==,size_16,color_FFFFFF,t_70#pic_center" alt=" Insert picture description here ">
user name :
<img src="https://img-blog.csdnimg.cn/20200818163520241.png#pic_center" alt=" Insert picture description here ">
password :
<img src="https://img-blog.csdnimg.cn/20200818163536872.png#pic_center" alt=" Insert picture description here ">
Construct the corresponding statement , Use css Select with the selector
driver.find_element_by_css_selector("[placeholder=' cell-phone number / mailbox / user name ']").send_keys(user)
driver.find_element_by_css_selector("[placeholder=' password ']").send_keys(password)Successfully entered (4) Click the login button
<img src="https://img-blog.csdnimg.cn/20200818163555584.png#pic_center" alt=" Insert picture description here ">
driver.find_element_by_css_selector("button").click()Click to go to
<img src="https://img-blog.csdnimg.cn/20200818163609117.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3RhbnN0eV96aA==,size_16,color_FFFFFF,t_70#pic_center" alt=" Insert picture description here ">
3. Check in
(1) It is found here that clicking on the avatar will jump to the personal Center , Direct constructor to access new web pages
new_window='window.open("{}")'.format("https://i.csdn.net/#/uc/profile")#js function , This method is applicable to all browsers
driver.execute_script(new_window)Successful entry
<img src="https://img-blog.csdnimg.cn/202008181636348.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3RhbnN0eV96aA==,size_16,color_FFFFFF,t_70#pic_center" alt=" Insert picture description here "> (2) Jump to the check-in page
I found here that the web links of each button will be different , So I just use js Jump to a new page
new_window = 'window.open("{}")'.format("https://i.csdn.net/#/uc/reward") # js function , This method is applicable to all browsers
driver.execute_script(new_window)<img src="https://img-blog.csdnimg.cn/20200818163723581.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3RhbnN0eV96aA==,size_16,color_FFFFFF,t_70#pic_center" alt=" Insert picture description here "> <img src="https://img-blog.csdnimg.cn/20200818163743948.png#pic_center" alt=" Insert picture description here ">
After the experiment, it is found that signing in and completing signing in class Properties are different
No sign in yes :handle_box to_sign The completion of check-in is :handle_box has_sign The lucky draw is :handle_box to_reward Construction code
try:
elem=driver.find_element_by_xpath("//div[@class='handle_box has_sign']")
except:
print(" You may not have signed in yet or you can draw a lottery ")
else:
messagebox.showinfo(" error ", " You have signed in ")
driver.quit()
sys.exit(1)
# If you have completed the check-in, exit
try:
elem=driver.find_element_by_xpath("//div[@class='handle_box to_reward']")
except:
print(" You haven't signed in yet ")
else:
messagebox.showinfo(" Congratulations ", " You can go to the lucky draw ")
driver.quit()
sys.exit(1)
# Tips can draw
try:
elem=driver.find_element_by_xpath("//div[@class='handle_box to_sign']")
except:
messagebox.showinfo(" error ", " No corresponding element found ")
driver.quit()
sys.exit(1)
else:
elem.click()Check in completed successfully
Two 、 Summary of corresponding knowledge points
1. How to select elements
find_element_by_class_name: according to class location
find_element_by_css_selector: according to css location
find_element_by_id: according to id location
find_element_by_link_text: Locate... According to the text of the link
find_element_by_name: Locate by node name
find_element_by_partial_link_text: Locate... According to the text of the link , Just include it in the whole text
find_element_by_tag_name: adopt tag location
find_element_by_xpath: Use Xpath Positioning
PS: hold element Change it to elements All eligible elements will be located , Return to one List
such as :find_elements_by_class_name
The return is web_element object
2. Browser window switch
If you jump to a new web page, you need to switch the browser window , Otherwise, he would still look for it on the original web page , Will report a mistake
for handle in driver.window_handles:
driver.switch_to.window(handle)
if " personal " in driver.title:
breakGo back to the original
# mainWindow Variable holds the handle of the current window mainWindow = wd.current_window_handle
Here is to save the current web page first handle, Convenient return
3.js Execution of statements
new_window = 'window.open({}")'.format("https://i.csdn.net/#/uc/reward") # js function , This method is applicable to all browsers
driver.execute_script(new_window)4.tkinter
The method adopted in this project :
def set_init_window(self):
self.init_window_name.title("CSDN Automatic check in ") # title
self.init_window_name.geometry() # Set window size , Set the window position
self.init_label=Label(self.init_window_name,text=" account number : ")
self.init_label.grid()#x=0,y=0
self.user=Entry(self.init_window_name) # Create input box
self.user.grid(row=0,column=1)
self.init_label2=Label(self.init_window_name,text=" password : ")
self.init_label2.grid(row=1,column=0)
self.password=Entry(self.init_window_name)
self.password.grid(row=1,column=1)
self.w=Button(text=" Sign in ", bg="lightblue", width=10,command=self.driver)
self.w.grid()tk Specific use of Library :
边栏推荐
- 跨域和JSONP
- How to view kubernetes API traffic by grabbing packets
- Error reported using worker: uncaught domexception: failed to construct 'worker': script at***
- 持续测试和质量保障的关系
- 用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧
- LSF opens job idle information to view the CPU time/elapse time usage of the job
- 对抗训练理论分析:自适应步长快速对抗训练
- Why traifik ingress?
- 2021-11-21: map[i][j] = = 0, which means that (I, J) is an ocean. If you cross it, the cost will be
- What are the two types of digital factories
猜你喜欢

Cvpr2022 𞓜 thin domain adaptation

飞桨产业级开源模型库:加速企业AI任务开发与应用

Cross domain and jsonp
![[applet] realize the effect of double column commodities](/img/e3/b72955c1ae67ec124520ca46c22773.png)
[applet] realize the effect of double column commodities
![[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.](/img/3f/988ed31a3f1cdc92deed121ed8d4ec.png)
[redis advanced ziplist] if someone asks you what is a compressed list? Please dump this article directly to him.

对抗训练理论分析:自适应步长快速对抗训练

Zhongshanshan: engineers after being blasted will take off | ONEFLOW u

13 `bs_duixiang.tag标签`得到一个tag对象

An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!

Real time computing framework: Flink cluster construction and operation mechanism
随机推荐
Icml'22 | progcl: rethinking difficult sample mining in graph contrast learning
Real time computing framework: Spark cluster setup and introduction case
What is memory out of order access?
DML操作
Real time computing framework: Flink cluster construction and operation mechanism
2022 postgraduate entrance examination experience sharing [preliminary examination, school selection, re examination, adjustment, school recruitment and social recruitment]
【CVPR 2022】高分辨率小目标检测:Cascaded Sparse Query for Accelerating High-Resolution Smal Object Detection
Talk to Wu Jiesheng, head of Alibaba cloud storage: my 20 years of data storage (unlimited growth)
Map design
[CVPR 2020 oral] a physics based noise formation model for extreme low light raw denoising
Data management: business data cleaning and implementation scheme
Devops culture: Amazon leadership principles
Social recruitment interview is indispensable -- 1000 interview questions for Android engineers from Internet companies
[CVPR 2022] high resolution small object detection: cascaded sparse query for accelerating high resolution smal object detection
一次 MySQL 误操作导致的事故,「高可用」都顶不住了!
[technology planting grass] skillfully use cloud function to create wechat web page authorization public service
Everything I see is the category of my precise positioning! Open source of a new method for saliency map visualization
version `ZLIB_1.2.9‘ not found (required by /lib64/libpng16.so.16)
持续测试和质量保障的关系
How to view kubernetes API traffic by grabbing packets