Commit ca02d78d authored by huangiyu's avatar huangiyu

1

parent 6ce39c7d
......@@ -107,8 +107,8 @@ class SlideUtils:
"""
使用pyautogui实现滑块并自定义轨迹方程
"""
print(f"睡眠0.5秒后点击移动")
time.sleep(0.5)
print(f"睡眠2.5秒后点击移动")
time.sleep(2.5)
xx = x + offset + offset_increase
pyautogui.moveTo(x, y, duration=0.1)
pyautogui.mouseDown()
......@@ -116,15 +116,26 @@ class SlideUtils:
pyautogui.moveTo(x + int(offset * random.randint(15, 23) / 20), y, duration=0.28)
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(-6, 6)
y += random.randint(-3, 3)
pyautogui.moveTo(xx, y, duration=0.8)
print("睡眠1秒后松开")
time.sleep(0.5)
time.sleep(0.2)
import math
pyautogui.moveRel(3, random.randint(-30, 10), duration=0.3)
pyautogui.moveRel(-3, random.randint(-30, 10), duration=0.2)
pyautogui.moveRel(0, random.randint(-30, 10), duration=0.3)
time.sleep(0.3)
move_range = 15
while_count = 0
while while_count< 3:
while_count +=1
move_x = random.randint(-move_range, move_range)
# 生成随机的上下移动距离
move_y = random.randint(-10, 10)
# 移动鼠标
pyautogui.moveRel(move_x, move_y, duration=0.2)
time.sleep(0.2) # 停顿一段时间
# 回到原始位置
pyautogui.moveTo(xx, y, duration=0.2)
time.sleep(0.2) # 停顿一段时间
print("松开")
pyautogui.mouseUp()
......@@ -133,8 +144,8 @@ class SlideUtils:
"""
使用pyautogui实现滑块并自定义轨迹方程
"""
# print(f"睡眠2秒后点击移动")
# time.sleep(2)
print(f"睡眠2秒后点击移动")
time.sleep(1)
xx = x + offset + offset_increase
pyautogui.moveTo(x, y, duration=0.5)
pyautogui.mouseDown()
......@@ -147,10 +158,21 @@ class SlideUtils:
print("睡眠1秒后松开")
time.sleep(0.5)
import math
pyautogui.moveRel(3, random.randint(-30, 10), duration=0.3)
pyautogui.moveRel(-3, random.randint(-30, 10), duration=0.2)
pyautogui.moveRel(0, random.randint(-30, 10), duration=0.3)
time.sleep(0.3)
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) # 停顿一段时间
print("松开")
pyautogui.mouseUp()
# print(f"睡眠2秒后点击
......@@ -374,7 +396,7 @@ 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' limit 1000"
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' limit 100000"
query_spider = mysql_zdzs_proxy(query_spider_sql)
index = 0
len_ = len(query_spider)
......@@ -390,6 +412,10 @@ def get_cookie():
url = row['url']
print(url)
driver.get(url)
while driver.title == '京东(JD.COM)-正品低价、品质保障、配送及时、轻松购物!':
print(url)
driver.get(url)
time.sleep(0.5)
# element_present = WebDriverWait(driver, 10).until(
# any_of_elements_present((By.ID, "J_main"), (By.CLASS_NAME, "verifyBtn"))
# )
......@@ -579,6 +605,10 @@ def get_cookie():
# 判断是否跳转了登录
if '<title>京东-欢迎登录</title>' in text:
return get_cookie()
if driver.title == '京东(JD.COM)-正品低价、品质保障、配送及时、轻松购物!':
print("验证后还是登录,先跳过。")
continue
Response = etree.HTML(text)
dataList = []
......
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