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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
| import random import time from pymouse import PyMouse
import option as option from selenium.webdriver import Chrome, ActionChains from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
options = Options() options.add_argument('--disable-blink-features=AutomationControlled')
options.add_argument('--ignore-certificate-errors') options.add_argument('--ignore-ssl-errors')
options.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])
web = Chrome(options=options)
web.implicitly_wait(1)
num = [ 2, 4, 4, 4, 7, 4, 3, 3, 3, 3, 3, 5, 5, 5, 4 ]
def get_num(list, num): if num in [3, 4, 5, 12]: a = random.randint(1, list[num]) b = random.randint(1, list[num]) if a == b: return [a] else: m = 0 n = 0 if a > b: m = a n = b else: m = b n = a return [n, m] else: return [random.randint(1, list[num])]
p = PyMouse()
for m in range(1000): web.get("https://www.wjx.cn/vm/OtYgtNJ.aspx") time.sleep(0.3) p.move(random.randint(0, 1000), random.randint(0, 1000))
try: content = web.find_element(By.XPATH, '/html/body/div[7]/div[3]/a[2]') web.execute_script("$(arguments[0]).click()", content) except Exception: print("没有找到上一次的结果") for i in range(15): list = get_num(num, i)
if len(list) == 1: try: content = web.find_element(By.XPATH, f'//*[@id="div{i + 1}"]/div[2]/div[{list[0]}]/span/a') web.execute_script("$(arguments[0]).click()",content) time.sleep(0.2) except Exception: print("="*12) print(i+1) print(list[0]) print("="*12) else: for n in range(list[0], list[1]): try: content = web.find_element(By.XPATH, f'//*[@id="div{i + 1}"]/div[2]/div[{n + 1}]/span/a') web.execute_script("$(arguments[0]).click()",content) except Exception: print("error") time.sleep(0.2) web.find_element(By.XPATH, '//*[@id="q16"]').send_keys("暂无意见,自我感觉良好")
content = web.find_element(By.XPATH, '//*[@id="ctlNext"]') web.execute_script("$(arguments[0]).click()",content) time.sleep(0.5)
p.click(858, 491) p.move(random.randint(0, 1000), random.randint(0, 1000)) time.sleep(1) p.move(858, 491)
try: content = web.find_element(By.XPATH, '//*[@id="rectMask"]') web.execute_script("$(arguments[0]).click()",content) time.sleep(1) except Exception: print("没有找到点击智能验证") try: content = web.find_element(By.XPATH, '/html/body/div[8]/span[1]/a') web.execute_script("$(arguments[0]).click()",content) time.sleep(1) except Exception: print("没有找到点击x号") time.sleep(0.5)
try: content = web.find_element(By.XPATH, '//*[@id="nc_1__scale_text"]/span') ActionChains(web).drag_and_drop_by_offset(content, 260, 1).perform() except Exception: print(1) print("没有找到拖动滑块")
time.sleep(2.5)
|