main.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. # This sample code uses the Appium python client v2
  2. # pip install Appium-Python-Client
  3. # Then you can paste this into a file and simply run with Python
  4. import random
  5. import types
  6. from typing import Union
  7. from appium import webdriver
  8. from selenium.common import TimeoutException
  9. from selenium.webdriver.support.ui import WebDriverWait
  10. from appium.webdriver.common.appiumby import AppiumBy
  11. from datetime import datetime
  12. import time
  13. import os
  14. import sys
  15. import getopt
  16. # import winsound
  17. # For W3C actions
  18. from selenium.webdriver.common.action_chains import ActionChains
  19. from selenium.webdriver.common.actions import interaction
  20. from selenium.webdriver.common.actions.action_builder import ActionBuilder
  21. from selenium.webdriver.common.actions.pointer_input import PointerInput
  22. from selenium.webdriver.support import expected_conditions
  23. isProfession = False
  24. driver = ''
  25. # 起始id
  26. startId = 10001
  27. # 结束id
  28. endId = 12900
  29. # ignores
  30. ignores = [] # [11139,10436,12843,10130,10437,10934] # 6.0吋屏以下的机型,乎略名称长度超过16个字的院校,防止界面交互遮挡
  31. # indicate, higher priority than start-end for no-seq targets
  32. # targets = [70054,70055,70056,70057,70058,70059,70060,70062,70063,70064,70065,70066,70067,70068,70069,70070,70071,70072,70073,70074,70075,70076,70077,70078,70079,70080,70081,70082,70083,70084,70085,70086,70087,70088,70089,70090,70091,70092,70093,70094,70095,70096,70327,70328,70329,70330,70331,70332,70333,70334,70335,70336,70337,70338,70339,70340,70341,70342,70343,70344,70345,70346,70347,70348,70349,70350,70351,70352,70353,70354,70355,70356,70357,70358,70360,70361,70362,70363,70364,70365,70366,70367,70368,70369,70370,70371,70372,70373,70374,70375,70376,70377,70378,70379,70380,70381,70382,70383,70384,70385,70386,70387,70388,70389,70390,70391]
  33. targets = [12713,12366,12436,11703,11498,12719,11975,12603,12854,11614,11451,11504,11446,11556,12834,11411,11915,11581,11671,11728,12525,11999,12662,11888,11953,12030,12342,11706,12298]
  34. card_id = "15654078" # AnHui WIFI 20106276 / 132278
  35. card_pwd = "357108"
  36. phone = '13203226079' # 19918180919/Myy123456 HeNan / #18506112645 Hht123456 HuBei / #18500040805[Jlzy123456]
  37. phone_pwd = 'Fy123456'
  38. hide_guide = False
  39. stop = False
  40. retry_times_max = 1 # 搜索loading时,间隔几次重新点击搜索
  41. retry_current = 0 # 暂时没有用途了
  42. batch_count = 3 # 有几个批次
  43. subject_default_top = True # 默认理科、物理
  44. plan_change_years = [1] # 计划取几年?从 1 开始
  45. profession_change_years = [1] # 专业取几年?从 1 开始
  46. # 登录方式 1 卡号 2 手机密码
  47. loginType = 1
  48. # 数据类型 1 招生计划 2 历年录取 3 两者都有
  49. dataType = 2
  50. def randomSleep():
  51. rd = random.choice([0.5, 3.0, 1.5, 2.5, 1, 2, 0, 1.2, 0, 3, 4, 5])
  52. if rd: time.sleep(rd/1.0)
  53. def init():
  54. global driver
  55. global isProfession
  56. print('程序启动')
  57. caps = {}
  58. caps["platformName"] = "Android"
  59. caps["appium:platformVersion"] = "6.0"
  60. caps["appium:deviceName"] = "emulator-5554"
  61. caps["appium:appPackage"] = "com.eagersoft.youzy.youzy"
  62. # .mvvm.ui.login.LoginAndRegisterSelectActivity
  63. # .mvvm.ui.college.FindCollegeActivity
  64. caps["appium:appActivity"] = ".mvvm.ui.login.LoginAndRegisterSelectActivity"
  65. caps["appium:resetKeyboard"] = True
  66. caps["appium:ensureWebviewsHavePages"] = True
  67. caps["appium:nativeWebScreenshot"] = True
  68. caps["appium:newCommandTimeout"] = 3600
  69. caps["appium:connectHardwareKeyboard"] = True
  70. driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
  71. # 不要混合使用隐式和显式等待。这样做会导致不可预测的等待时间。例如,将隐式等待设置为10秒,将显式等待设置为15秒, 可能会导致在20秒后发生超时。
  72. # driver.implicitly_wait(2)
  73. def start():
  74. init()
  75. login()
  76. def alarm():
  77. if sys.platform.startswith('win'):
  78. pass # winsound.Beep(1000, 3000)
  79. elif sys.platform.startswith('darwin'):
  80. os.system("say --voice=\"Mei-Jia\" 出错了,请尽快处理")
  81. def getForkRange():
  82. if targets:
  83. return targets
  84. else:
  85. return range(startId, endId + 1)
  86. def login():
  87. if loginType == 1:
  88. login_by_card()
  89. elif loginType == 2:
  90. login_by_phone()
  91. else:
  92. login_by_card()
  93. def login_success():
  94. # 弹出了验证窗口,请在20s内通过验证
  95. entrance_xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/" \
  96. "android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/" \
  97. "android.widget.FrameLayout/android.view.ViewGroup/androidx.viewpager.widget.ViewPager/" \
  98. "android.view.ViewGroup/android.widget.LinearLayout/android.widget.FrameLayout/" \
  99. "android.view.ViewGroup[1]/android.view.ViewGroup/android.view.ViewGroup[2]/" \
  100. "androidx.viewpager.widget.ViewPager/androidx.recyclerview.widget.RecyclerView/" \
  101. "android.view.ViewGroup[1]"
  102. modal_id = "com.eagersoft.youzy.youzy:id/click_close_dialog_activity_pop"
  103. try:
  104. def load(x):
  105. modal = find_ele_by_id(modal_id)
  106. if modal is not None:
  107. modal.click()
  108. return True
  109. else:
  110. if find_ele_by_xpath(entrance_xpath) is not None:
  111. return True
  112. else:
  113. return False
  114. return False
  115. except:
  116. print('超时了')
  117. sys.exit()
  118. alarm()
  119. WebDriverWait(driver, 120).until(load)
  120. # 登录成功并且关闭了弹窗
  121. try:
  122. # 进入学校列表
  123. entrance = find_ele_by_xpath(entrance_xpath)
  124. entrance.click()
  125. # 开始工作
  126. global_begin_time = time.time()
  127. college_range = getForkRange()
  128. for i in college_range:
  129. if i in ignores: continue
  130. current_no = college_range.index(i) + 1
  131. time_diff = time.time() - global_begin_time
  132. print('进度统计:', current_no, 'OF', len(college_range), 'IN', time_diff / 3600, 'Hours')
  133. if not stop:
  134. auto_click(i)
  135. else:
  136. print('结束')
  137. return
  138. time_diff = time.time() - global_begin_time
  139. current_speed1 = time_diff / current_no
  140. current_speed2 = current_no * 3600 / time_diff
  141. print('速率统计:', current_speed1, 'Seconds of Each.', current_speed2, 'Completed Per Hour.')
  142. # auto_click(startId)
  143. except Exception as e:
  144. print('错误:', repr(e))
  145. def login_by_card():
  146. el1 = find_ele_by_id("com.eagersoft.youzy.youzy:id/click_login_register_card")
  147. el1.click()
  148. el3 = find_ele_by_id("com.eagersoft.youzy.youzy:id/cardNumber")
  149. el3.send_keys(card_id)
  150. el4 = find_ele_by_id("com.eagersoft.youzy.youzy:id/password")
  151. el4.send_keys(card_pwd)
  152. el5 = find_ele_by_id("com.eagersoft.youzy.youzy:id/checkbox")
  153. el5.click()
  154. el6 = find_ele_by_id("com.eagersoft.youzy.youzy:id/click_next")
  155. el6.click()
  156. login_success()
  157. def login_by_phone():
  158. el2 = driver.find_element(by=AppiumBy.ID, value="com.eagersoft.youzy.youzy:id/click_login_register_mobile")
  159. el2.click()
  160. time.sleep(1)
  161. el3 = driver.find_element(by=AppiumBy.ID, value="com.eagersoft.youzy.youzy:id/click_login_by_password")
  162. el3.click()
  163. # time.sleep(0.5)
  164. # el4 = driver.find_element(by=AppiumBy.ID, value="com.eagersoft.youzy.youzy:id/account")
  165. # el4.send_keys(phone)
  166. # time.sleep(1)
  167. # el5 = driver.find_element(by=AppiumBy.ID, value="com.eagersoft.youzy.youzy:id/password")
  168. # el5.send_keys(phone_pwd)
  169. # time.sleep(1)
  170. # el6 = driver.find_element(by=AppiumBy.ID, value="com.eagersoft.youzy.youzy:id/checkbox")
  171. # el6.click()
  172. # time.sleep(1)
  173. # el7 = driver.find_element(by=AppiumBy.ID, value="com.eagersoft.youzy.youzy:id/click_login_register_mobile")
  174. # el7.click()
  175. time.sleep(15)
  176. login_success()
  177. def change_tab(tabIndex=1) -> bool:
  178. print('切换tab')
  179. # 540 740 1213
  180. # 招生计划
  181. el_plan = find_ele_by_xpath(
  182. "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/"
  183. "android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/"
  184. "android.widget.RelativeLayout/android.view.ViewGroup/android.view.ViewGroup[1]/"
  185. "android.widget.LinearLayout/android.widget.HorizontalScrollView/"
  186. "android.widget.LinearLayout/androidx.appcompat.app.ActionBar.Tab/"
  187. "android.view.ViewGroup/android.widget.TextView[contains(@text,'招生计划')]", 5)
  188. # print(el_plan)
  189. print(el_plan)
  190. change_success = False
  191. if tabIndex == 1:
  192. if el_plan is not None:
  193. el_plan.click()
  194. change_success = True
  195. elif tabIndex == 2:
  196. try:
  197. # 历年录取
  198. el_enter = find_ele_by_xpath(
  199. "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/"
  200. "android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/"
  201. "android.widget.RelativeLayout/android.view.ViewGroup/android.view.ViewGroup[1]/"
  202. "android.widget.LinearLayout/android.widget.HorizontalScrollView/"
  203. "android.widget.LinearLayout/androidx.appcompat.app.ActionBar.Tab/android.view.ViewGroup/"
  204. "android.widget.TextView[contains(@text,'历年录取')]", 5)
  205. # print(el_enter)
  206. if el_enter is not None:
  207. el_enter.click()
  208. change_success = True
  209. except:
  210. if el_plan is not None:
  211. el_plan.click()
  212. # 历年录取
  213. # time.sleep(1) # tab会横向滑动,稍等会
  214. el_enter = find_ele_by_xpath(
  215. "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/"
  216. "android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/"
  217. "android.widget.RelativeLayout/android.view.ViewGroup/android.view.ViewGroup[1]/"
  218. "android.widget.LinearLayout/android.widget.HorizontalScrollView/"
  219. "android.widget.LinearLayout/androidx.appcompat.app.ActionBar.Tab/android.view.ViewGroup/"
  220. "android.widget.TextView[contains(@text,'历年录取')]")
  221. # print(el_enter)
  222. if el_enter is not None:
  223. el_enter.click()
  224. change_success = True
  225. else:
  226. if el_plan is not None:
  227. el_plan.click()
  228. change_success = True
  229. return change_success
  230. def change_time(count: int = 2):
  231. print('切换年份')
  232. tv_year = find_ele_by_id("com.eagersoft.youzy.youzy:id/tv_year")
  233. tv_year.click()
  234. el_year = find_ele_by_xpath(f"/hierarchy/android.widget.FrameLayout/android.widget"
  235. f".LinearLayout/android.widget.FrameLayout/android.widget"
  236. f".FrameLayout/android.widget.FrameLayout/android.widget"
  237. f".FrameLayout/android.view.ViewGroup/android.widget"
  238. f".FrameLayout/android.view.ViewGroup/android.view."
  239. f"ViewGroup/android.widget.ScrollView/android.widget"
  240. f".LinearLayout/android.view.ViewGroup/android.widget"
  241. f".LinearLayout/androidx.recyclerview.widget"
  242. f".RecyclerView/android.view.ViewGroup[{count}]/android.widget.TextView")
  243. el_year.click()
  244. def open_profession():
  245. print('切换专业分数线')
  246. el_switch = find_ele_by_xpath(
  247. "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/"
  248. "android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/"
  249. "android.widget.RelativeLayout/android.view.ViewGroup/android.view.ViewGroup[1]/"
  250. "androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.ScrollView/"
  251. "android.view.ViewGroup/android.widget.LinearLayout/android.view.View")
  252. el_switch_mid_x = el_switch.location['x'] + el_switch.size['width'] / 2
  253. el_switch_mid_y = el_switch.location['y'] + el_switch.size['height'] / 2
  254. print(el_switch, el_switch_mid_x, el_switch_mid_y)
  255. actions = ActionChains(driver)
  256. actions.w3c_actions = ActionBuilder(driver, mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))
  257. actions.w3c_actions.pointer_action.move_to_location(el_switch_mid_x, el_switch_mid_y)
  258. actions.w3c_actions.pointer_action.pointer_down()
  259. actions.w3c_actions.pointer_action.pause(0.1)
  260. actions.w3c_actions.pointer_action.release()
  261. actions.perform()
  262. def change_batch(count):
  263. # 3个科目都点击一次
  264. print('打开批次面板', count)
  265. for index in range(count):
  266. # el_dropdown = find_ele_by_id("com.eagersoft.youzy.youzy:id/ll_select_college_batch")
  267. el_dropdown = WebDriverWait(driver, 5, 0.5).until(expected_conditions.presence_of_element_located(
  268. (AppiumBy.ID, "com.eagersoft.youzy.youzy:id/ll_select_college_batch")))
  269. if el_dropdown is not None:
  270. el_dropdown.click()
  271. else:
  272. # 表示元素有,但不可见,需要滚动至可见
  273. driver.execute_script("arguments[0].scrollIntoView();", el_dropdown)
  274. el_dropdown.click()
  275. batch_item_path = f"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget" \
  276. f".FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget" \
  277. f".FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.view" \
  278. f".ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.widget" \
  279. f".LinearLayout/android.view.ViewGroup/android.widget.LinearLayout/androidx" \
  280. f".recyclerview.widget.RecyclerView/android.view.ViewGroup[{index + 1}]"
  281. try:
  282. el_batch_item = find_ele_by_xpath(batch_item_path)
  283. el_batch_item.click()
  284. except Exception as ex:
  285. print('切换批次异常,索引', index, '乎略异常', ex)
  286. el_ddl_close = find_ele_by_id('com.eagersoft.youzy.youzy:id/iv_close')
  287. el_ddl_close.click()
  288. randomSleep()
  289. def cicle():
  290. change_batch(batch_count)
  291. # time.sleep(0.5)
  292. # 切换科目
  293. subtype_tab = find_ele_by_id("com.eagersoft.youzy.youzy:id/tv_subject_type")
  294. if subtype_tab is not None:
  295. subtype_tab.click()
  296. # time.sleep(0.5)
  297. subject_index = 1
  298. if subject_default_top: subject_index = 2
  299. subject_path = f"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget" \
  300. f".FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget" \
  301. f".FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.view.ViewGroup/android" \
  302. f".view.ViewGroup/android.widget.ScrollView/android.widget.LinearLayout/android.view" \
  303. f".ViewGroup/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView/android" \
  304. f".view.ViewGroup[{subject_index}]"
  305. el29 = find_ele_by_xpath(subject_path)
  306. if el29 is not None:
  307. el29.click()
  308. # time.sleep(0.5)
  309. change_batch(batch_count - 1)
  310. # time.sleep(0.5)
  311. def get_data(tab_index, change_years):
  312. if change_tab(tab_index):
  313. # time.sleep(1)
  314. if tab_index == 2:
  315. open_profession()
  316. # time.sleep(1)
  317. for year in change_years:
  318. if year == 1:
  319. cicle()
  320. else:
  321. # 从第二个年份开始切换
  322. change_time(year)
  323. cicle()
  324. else:
  325. raise Exception("切换tab失败")
  326. def is_error() -> bool:
  327. try:
  328. return (WebDriverWait(driver, 0.5, 0.25).until(expected_conditions.visibility_of_element_located(
  329. (AppiumBy.ID, "com.eagersoft.youzy.youzy:id/errorViewRelativeLayout"))) or
  330. WebDriverWait(driver, 0.5, 0.25).until(
  331. expected_conditions.visibility_of_element_located(
  332. (AppiumBy.ID, "com.eagersoft.youzy.youzy:id/load_more_load_fail_view"))))
  333. except:
  334. return False
  335. def retry():
  336. try:
  337. retry_button = WebDriverWait(driver, 2, 0.5).until(
  338. expected_conditions.visibility_of_element_located(
  339. (AppiumBy.ID, "com.eagersoft.youzy.youzy:id/errorStateButton")))
  340. if retry_button is not None:
  341. retry_button.click()
  342. else:
  343. retry_button = WebDriverWait(driver, 2, 0.5).until(
  344. expected_conditions.visibility_of_element_located(
  345. (AppiumBy.ID, "com.eagersoft.youzy.youzy:id/tv_prompt")))
  346. if retry_button is not None:
  347. retry_button.click()
  348. except Exception as ex:
  349. print('retry ignored', ex)
  350. def is_loading() -> bool:
  351. try:
  352. return (WebDriverWait(driver, 0.5, 0.25).until(expected_conditions.visibility_of_element_located(
  353. (AppiumBy.ID, "com.eagersoft.youzy.youzy:id/image_loading"))) or
  354. WebDriverWait(driver, 0.5, 0.25).until(expected_conditions.visibility_of_element_located(
  355. (AppiumBy.ID, "com.eagersoft.youzy.youzy:id/load_more_load_end_view"))))
  356. except:
  357. return False
  358. def find_ele_by_id(ele_id: str, timeout: int = 2, poll_frequency: int = 0.5, deep: int = 0):
  359. loading = False
  360. error = False
  361. try:
  362. def find(x):
  363. nonlocal loading
  364. nonlocal error
  365. if is_error():
  366. print("error by id", x)
  367. error = True
  368. loading = False
  369. return False
  370. if is_loading():
  371. print("loading")
  372. loading = True
  373. error = False
  374. return False
  375. return x.find_element(by=AppiumBy.ID, value=ele_id) is not None
  376. WebDriverWait(driver, timeout, poll_frequency).until(find)
  377. return driver.find_element(by=AppiumBy.ID, value=ele_id)
  378. except:
  379. if loading:
  380. print("新一轮loading", deep)
  381. if retry_times_max > 0 and deep > 0 and deep % retry_times_max == 0:
  382. try:
  383. print('重新触发查询', deep, '%', retry_times_max)
  384. btn_search = driver.find_element(by=AppiumBy.ID, value="com.eagersoft.youzy.youzy:id/tv_search")
  385. btn_search.click()
  386. except Exception as e:
  387. print('重新触发查询 except', e)
  388. return find_ele_by_id(ele_id, timeout, poll_frequency, deep + 1)
  389. elif error:
  390. print("error,重试")
  391. retry()
  392. return find_ele_by_id(ele_id, timeout * 2, poll_frequency, deep + 1)
  393. else:
  394. return None
  395. def find_ele_by_xpath(ele_xpath: str, timeout: int = 2, poll_frequency: int = 0.5):
  396. loading = False
  397. error = False
  398. try:
  399. def find(x):
  400. nonlocal loading
  401. nonlocal error
  402. if is_error():
  403. print("error by path", x)
  404. error = True
  405. loading = False
  406. return False
  407. if is_loading():
  408. print("loading")
  409. loading = True
  410. error = False
  411. return False
  412. return x.find_element(by=AppiumBy.XPATH, value=ele_xpath)
  413. return WebDriverWait(driver, timeout, poll_frequency).until(find)
  414. except:
  415. if loading:
  416. print("新一轮,loading")
  417. return find_ele_by_xpath(ele_xpath, timeout, poll_frequency)
  418. elif error:
  419. print("新一轮,重试")
  420. retry()
  421. return find_ele_by_xpath(ele_xpath, timeout, poll_frequency)
  422. else:
  423. return None
  424. def find_college(college_id: Union[str, int]) -> Union[bool, 'WebElement']:
  425. el23 = find_ele_by_id("com.eagersoft.youzy.youzy:id/et_input")
  426. el23.send_keys(college_id)
  427. el24 = find_ele_by_id("com.eagersoft.youzy.youzy:id/tv_search")
  428. el24.click()
  429. empty_container = find_ele_by_id("com.eagersoft.youzy.youzy:id/emptyViewRelativeLayout", timeout=2)
  430. if empty_container is not None:
  431. return False
  432. else:
  433. college = find_ele_by_id("com.eagersoft.youzy.youzy:id/cl_parent")
  434. if college is not None:
  435. return college
  436. return False
  437. def back():
  438. el_back = find_ele_by_id("com.eagersoft.youzy.youzy:id/iv_back")
  439. if el_back is not None:
  440. print("返回页面")
  441. el_back.click()
  442. def auto_click(id):
  443. global hide_guide
  444. global stop
  445. global retry_current
  446. global dataType
  447. global loginType
  448. print('当前id:', id, datetime.now())
  449. # 开始搜索
  450. el_search = find_ele_by_id("com.eagersoft.youzy.youzy:id/click_search")
  451. if el_search is not None:
  452. el_search.click()
  453. college = find_college(id)
  454. if isinstance(college, bool):
  455. return
  456. else:
  457. college.click()
  458. retry_current = 0
  459. try:
  460. if not hide_guide:
  461. print('等待关闭引导')
  462. time.sleep(6)
  463. # actions = ActionChains(driver)
  464. # actions.w3c_actions = ActionBuilder(driver, mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))
  465. # actions.w3c_actions.pointer_action.move_to_location(507, 1537)
  466. # actions.w3c_actions.pointer_action.pointer_down()
  467. # actions.w3c_actions.pointer_action.pause(0.1)
  468. # actions.w3c_actions.pointer_action.release()
  469. # actions.perform()
  470. hide_guide = True
  471. # time.sleep(1)
  472. if dataType == 1:
  473. get_data(1, plan_change_years)
  474. elif dataType == 2:
  475. get_data(2, profession_change_years)
  476. elif dataType == 3:
  477. get_data(1, plan_change_years)
  478. get_data(2, profession_change_years)
  479. # 回退两次,清除学校列表缓存
  480. back()
  481. back()
  482. except Exception as ex:
  483. print('get_data exception', ex)
  484. alarm()
  485. back()
  486. back()
  487. auto_click(id)
  488. if __name__ == '__main__':
  489. try:
  490. args = sys.argv[1:]
  491. longopts = ['loginType=', 'dataType=']
  492. shortopts = []
  493. options, args = getopt.getopt(args, shortopts, longopts)
  494. for name, value in options:
  495. print(name, value)
  496. if name in ('--loginType'):
  497. loginType = int(value)
  498. if name in '--dataType':
  499. dataType = int(value)
  500. except:
  501. print('运行参数解析错误')
  502. if dataType == 1:
  503. print('招生计划')
  504. elif dataType == 2:
  505. print('历年录取')
  506. else:
  507. print('招生计划和历年录取')
  508. start()