121.4-python-selenium+IDM:一个不太成熟的小项目P2


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from time import sleep
import gurl
url=gurl.URL.split("\"")[1]
passcode=gurl.URL.split("\'")[1]
print(url,"|",passcode)

"""
截取网址和提取码

"""
import os
from subprocess import call
from selenium import webdriver


option = webdriver.ChromeOptions()
option.add_argument("--user-data-dir=D:\Bma\py\mail\chrome_new")
sleep(1)
browser = webdriver.Chrome(options=option)    #打开驱动
browser.get(url)   #进入网站
browser.implicitly_wait(5)  #最大反应时间

elements = browser.find_elements_by_id('accessCode')
for element in elements:
      print(element.text)

      element.clear()     #清空输入框
      element.send_keys(passcode)       #输入accesscode

elements = browser.find_element_by_class_name('g-button-blue-large')
elements.click()
elements = browser.find_element_by_class_name("EOGexf")
elements.click()


elements = browser.find_element_by_class_name('filename')
elements.click()
elements = browser.find_element_by_class_name('zbyDdwb')
elements.click()
sleep(1)
elements = browser.find_element_by_class_name('g-button-blue')
elements.click()
elements = browser.find_element_by_class_name('g-button-menu')
elements.click()

elements = browser.find_elements_by_class_name('listener-link-api')

'''
els= browser.find_elements_by_class_name('listener-tip')
apis={}
ii=0
flnam={}
i=0

for el in els:
      flnam[i]=el.text
      i+=1

for element in elements:
      apis[ii]=element.text
      ii+=1
'''


'''
elements = browser.find_elements_by_id('accessCode')
for element in elements:
      print(element.text)

element.clear()     #清空输入框
element.send_keys(passcode)       #输入accesscode

elements = browser.find_element_by_class_name('g-button-blue-large')
elements.click()
elements = browser.find_element_by_class_name("EOGexf")
elements.click()
elements = browser.find_element_by_class_name("tools-share-save-hb")
elements.click()
'''
os.chdir("D:/downloads/idmdown/IDM")
for element in elements:
	call(['IDMan.exe','/a','/d',element.text])
"""
其实就是点点点,得到文件api后,传给IDM然后下载
"""
CTRL-/