Commit b9e730ec authored by huangiyu's avatar huangiyu

1

parent 44ee201c
......@@ -144,35 +144,17 @@ class SlideUtils:
"""
使用pyautogui实现滑块并自定义轨迹方程
"""
print(f"睡眠2秒后点击移动")
time.sleep(1)
xx = x + offset + offset_increase
pyautogui.moveTo(x, y, duration=0.5)
pyautogui.moveTo(x, y, duration=0.3)
pyautogui.mouseDown()
y += random.randint(9, 19)
pyautogui.moveTo(x + int(offset * random.randint(15, 23) / 20), y, duration=0.2)
pyautogui.moveTo(x + int(offset * random.randint(15, 23) / 20), y, duration=0.5)
y += random.randint(-9, 0)
pyautogui.moveTo(x + int(offset * random.randint(17, 21) / 20), y, duration=random.randint(20, 31) / 100)
y += random.randint(-2, 2)
pyautogui.moveTo(xx, y, duration=0.3)
print("睡眠1秒后松开")
time.sleep(0.5)
import math
while_count = 0
while while_count < 3:
move_range = random.randint(10, 30)
while_count += 1
move_x = random.randint(-move_range, move_range)
# 生成随机的上下移动距离
move_y = random.randint(-int(move_range/2), int(move_range/2))
# 移动鼠标
pyautogui.moveRel(move_x, move_y, duration=0.2)
time.sleep(0.1) # 停顿一段时间
# 回到原始位置
pyautogui.moveTo(xx, y, duration=0.2)
time.sleep(0.5) # 停顿一段时间
pyautogui.moveTo(xx + random.randint(-2, 2), y, duration=0.8)
duration=random.randint(50, 99) / 100
print(duration)
pyautogui.moveRel(0, random.randint(2, 20), duration=duration)
print("松开")
pyautogui.mouseUp()
# print(f"睡眠2秒后点击
......@@ -396,7 +378,8 @@ def get_cookie():
# query_spider_sql = f"SELECT id,url,mallId FROM DMP_SEARCH_SPIDER WHERE data_batch ='202401251550270001' and ID NOT IN (SELECT ID FROM DMP_SEARCH_DATA) and mallId = 'DS-JD' order by docID desc limit 10000"
# query_spider_sql = f"SELECT id,url,mallId FROM DMP_SEARCH_SPIDER WHERE ID NOT IN (SELECT ID FROM DMP_SEARCH_DATA) and mallId = 'DS-JD' and data_batch ='202403051815460001' order by id" \
# f" limit 100000"
query_spider_sql = f"SELECT id,url,mallId FROM DMP_SEARCH_SPIDER WHERE ID NOT IN (SELECT ID FROM DMP_SEARCH_DATA) and mallId = 'DS-JD' and project_id = '110' and (id like '%5' or id like '%6' or id like '%7' or id like '%8' or id like '%9' ) limit 100000"
# query_spider_sql = f"-- SELECT id,url,mallId FROM DMP_SEARCH_SPIDER WHERE ID NOT IN (SELECT ID FROM DMP_SEARCH_DATA) and mallId = 'DS-JD' and project_id = '41' and (id like '%5' or id like '%6' or id like '%7' or id like '%8' or id like '%9' ) limit 10000"
query_spider_sql = f"SELECT id,url,mallId FROM DMP_SEARCH_SPIDER WHERE data_batch ='202404180000000001' and ID NOT IN (SELECT ID FROM DMP_SEARCH_DATA) and mallId = 'DS-JD'"
query_spider = mysql_zdzs_proxy(query_spider_sql)
index = 0
len_ = len(query_spider)
......@@ -466,12 +449,16 @@ def get_cookie():
except:
print("点击“快速验证”按钮异常")
try:
WebDriverWait(driver, 2).until(
WebDriverWait(driver, 5).until(
EC.presence_of_element_located((By.XPATH, '//*[@id="cpc_img"]'))
)
except:
print("未查找到验证图片背景图,可能是旋转图片,换一种方式获取div")
pass
while_count_2 = 0
while while_count_2 < 30 and (
'快速验证' in text and '验证一下,购物无忧' in text) or '前方拥挤,请刷新重试' in text or 'class="title">加载中...</span></div></div><!----></div>' in text:
while_count_2 += 1
background = driver.find_element(by=By.XPATH, value='//*[@id="cpc_img"]')
background_url = background.get_attribute("src")
# 用来找到登录图片的小滑块
......@@ -513,17 +500,7 @@ def get_cookie():
text = driver.page_source
continue
except:
try:
driver.get(url)
WebDriverWait(driver, 5).until(
EC.presence_of_element_located((By.CLASS_NAME, "verifyBtn"))
)
except NoSuchElementException:
print("网页加载异常")
text = driver.page_source
continue
finally:
print("网页加载完成")
print("没成功,重试")
finally:
print("网页加载完成")
text = driver.page_source
......@@ -650,7 +627,6 @@ def get_cookie():
cookie = ''
for i in driver.get_cookies():
cookie = cookie + i['name'] + '=' + i['value'] + ';'
driver.quit()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment