Commit 3f158caf by Peng

no message

parent 694247a4
...@@ -85,7 +85,7 @@ class TkVideo(): ...@@ -85,7 +85,7 @@ class TkVideo():
# 等待页面初始加载 # 等待页面初始加载
time.sleep(random.randint(6, 10)) time.sleep(random.randint(6, 10))
export_orders = self.page_chrome.ele('xpath://span[text()="自定义"]', timeout=10) export_orders = self.page_chrome.ele('xpath://span[text()="自定义"]', timeout=13)
export_orders.click() export_orders.click()
print('点击自定义') print('点击自定义')
time.sleep(random.randint(5, 10)) time.sleep(random.randint(5, 10))
...@@ -102,9 +102,7 @@ class TkVideo(): ...@@ -102,9 +102,7 @@ class TkVideo():
# 初始目标日期为 deadline(可能已经是上个月的某一天) # 初始目标日期为 deadline(可能已经是上个月的某一天)
max_attempts = 31 for i in range(10):
while max_attempts > 0:
try: try:
xpath = ( xpath = (
f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]" f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]"
...@@ -112,7 +110,7 @@ class TkVideo(): ...@@ -112,7 +110,7 @@ class TkVideo():
f"//span[text()='{self.end_day}']/parent::div" f"//span[text()='{self.end_day}']/parent::div"
) )
print('结束日期 xpath::', xpath) print('结束日期 xpath::', xpath)
ele = self.page_chrome.ele(f"xpath={xpath}", timeout=5) ele = self.page_chrome.ele(f"xpath={xpath}", timeout=8)
ele.click() ele.click()
print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}') print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}')
self.get_data() self.get_data()
...@@ -133,24 +131,24 @@ class TkVideo(): ...@@ -133,24 +131,24 @@ class TkVideo():
def get_data(self): def get_data(self):
try: try:
self.page_chrome.ele('xpath://div[text()="更新"]', timeout=10).click() self.page_chrome.ele('xpath://div[text()="更新"]', timeout=13).click()
print('已点击更新') print('已点击更新')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://span[text()="下载数据"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://span[text()="Xlsx"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="Xlsx"]', timeout=13).click()
print('已点击Xlsx') print('已点击Xlsx')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://button[text()="下载数据"]', timeout=10).click() self.page_chrome.ele('xpath://button[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
# 点击首页 获取店铺名称 # 点击首页 获取店铺名称
self.page_chrome.ele('xpath://span[text()="首页"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="首页"]', timeout=13).click()
print('已点击首页') print('已点击首页')
sleep(randint(5, 10)) sleep(randint(5, 10))
...@@ -293,7 +291,11 @@ class TkVideo(): ...@@ -293,7 +291,11 @@ class TkVideo():
data = self.read_excel(EXCEL_FILE) data = self.read_excel(EXCEL_FILE)
processed_data = self.process_data(data, self.shop_name) processed_data = self.process_data(data, self.shop_name)
self.store_data_in_redis(self.r, processed_data) self.store_data_in_redis(self.r, processed_data)
try:
print('删除下载文件',EXCEL_FILE)
os.remove(EXCEL_FILE)
except:
print('删除数据失败')
def send_success_message_via_wechat(self): def send_success_message_via_wechat(self):
webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL
data = { data = {
......
...@@ -15,7 +15,7 @@ import redis ...@@ -15,7 +15,7 @@ import redis
import json import json
from pathlib import Path from pathlib import Path
import re import re
from sqlalchemy import create_engine
import random import random
class TkVideo(): class TkVideo():
...@@ -84,7 +84,7 @@ class TkVideo(): ...@@ -84,7 +84,7 @@ class TkVideo():
# 等待页面初始加载 # 等待页面初始加载
time.sleep(random.randint(6, 10)) time.sleep(random.randint(6, 10))
export_orders = self.page_chrome.ele('xpath://span[text()="自定义"]', timeout=10) export_orders = self.page_chrome.ele('xpath://span[text()="自定义"]', timeout=13)
export_orders.click() export_orders.click()
print('点击自定义') print('点击自定义')
time.sleep(random.randint(5, 10)) time.sleep(random.randint(5, 10))
...@@ -98,10 +98,7 @@ class TkVideo(): ...@@ -98,10 +98,7 @@ class TkVideo():
).click() ).click()
print(f'已输入开始时间{self.start_year} {self.start_month} 月 {self.start_day} 日') print(f'已输入开始时间{self.start_year} {self.start_month} 月 {self.start_day} 日')
time.sleep(random.randint(3, 5)) time.sleep(random.randint(3, 5))
for i in range(10):
max_attempts = 31
while max_attempts > 0:
try: try:
xpath = ( xpath = (
f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]" f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]"
...@@ -109,11 +106,11 @@ class TkVideo(): ...@@ -109,11 +106,11 @@ class TkVideo():
f"//span[text()='{self.end_day}']/parent::div" f"//span[text()='{self.end_day}']/parent::div"
) )
print('结束日期 xpath::', xpath) print('结束日期 xpath::', xpath)
ele = self.page_chrome.ele(f"xpath={xpath}", timeout=5) ele = self.page_chrome.ele(f"xpath={xpath}", timeout=8)
ele.click() ele.click()
print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}') print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}')
self.get_data() self.get_data()
time.sleep(random.randint(3, 5)) time.sleep(random.randint(5, 8))
return True # 成功返回 return True # 成功返回
except Exception as e: except Exception as e:
...@@ -130,24 +127,24 @@ class TkVideo(): ...@@ -130,24 +127,24 @@ class TkVideo():
def get_data(self): def get_data(self):
try: try:
self.page_chrome.ele('xpath://div[text()="更新"]', timeout=10).click() self.page_chrome.ele('xpath://div[text()="更新"]', timeout=13).click()
print('已点击更新') print('已点击更新')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://span[text()="下载数据"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://span[text()="Xlsx"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="Xlsx"]', timeout=13).click()
print('已点击Xlsx') print('已点击Xlsx')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://button[text()="下载数据"]', timeout=10).click() self.page_chrome.ele('xpath://button[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
# 点击首页 获取店铺名称 # 点击首页 获取店铺名称
self.page_chrome.ele('xpath://span[text()="首页"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="首页"]', timeout=13).click()
print('已点击首页') print('已点击首页')
sleep(randint(5, 10)) sleep(randint(5, 10))
...@@ -290,7 +287,11 @@ class TkVideo(): ...@@ -290,7 +287,11 @@ class TkVideo():
data = self.read_excel(EXCEL_FILE) data = self.read_excel(EXCEL_FILE)
processed_data = self.process_data(data, self.shop_name) processed_data = self.process_data(data, self.shop_name)
self.store_data_in_redis(self.r, processed_data) self.store_data_in_redis(self.r, processed_data)
try:
print('删除下载文件',EXCEL_FILE)
os.remove(EXCEL_FILE)
except:
print('删除数据失败')
def send_success_message_via_wechat(self): def send_success_message_via_wechat(self):
webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL
data = { data = {
......
...@@ -90,7 +90,7 @@ class TkVideo(): ...@@ -90,7 +90,7 @@ class TkVideo():
# 等待页面初始加载 # 等待页面初始加载
time.sleep(random.randint(6, 10)) time.sleep(random.randint(6, 10))
export_orders = self.page_edge.ele('xpath://span[text()="自定义"]', timeout=10) export_orders = self.page_edge.ele('xpath://span[text()="自定义"]', timeout=13)
export_orders.click() export_orders.click()
print('点击自定义') print('点击自定义')
time.sleep(random.randint(5, 10)) time.sleep(random.randint(5, 10))
...@@ -104,11 +104,7 @@ class TkVideo(): ...@@ -104,11 +104,7 @@ class TkVideo():
).click() ).click()
print(f'已输入开始时间{self.start_year} {self.start_month} 月 {self.start_day} 日') print(f'已输入开始时间{self.start_year} {self.start_month} 月 {self.start_day} 日')
time.sleep(random.randint(3, 5)) time.sleep(random.randint(3, 5))
for i in range(10):
max_attempts = 31
while max_attempts > 0:
try: try:
xpath = ( xpath = (
f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]" f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]"
...@@ -116,7 +112,7 @@ class TkVideo(): ...@@ -116,7 +112,7 @@ class TkVideo():
f"//span[text()='{self.end_day}']/parent::div" f"//span[text()='{self.end_day}']/parent::div"
) )
print('结束日期 xpath::', xpath) print('结束日期 xpath::', xpath)
ele = self.page_edge.ele(f"xpath={xpath}", timeout=5) ele = self.page_edge.ele(f"xpath={xpath}", timeout=8)
ele.click() ele.click()
print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}') print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}')
self.get_data() self.get_data()
...@@ -137,24 +133,24 @@ class TkVideo(): ...@@ -137,24 +133,24 @@ class TkVideo():
def get_data(self): def get_data(self):
try: try:
self.page_edge.ele('xpath://div[text()="更新"]', timeout=10).click() self.page_edge.ele('xpath://div[text()="更新"]', timeout=13).click()
print('已点击更新') print('已点击更新')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_edge.ele('xpath://span[text()="下载数据"]', timeout=10).click() self.page_edge.ele('xpath://span[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_edge.ele('xpath://span[text()="Xlsx"]', timeout=10).click() self.page_edge.ele('xpath://span[text()="Xlsx"]', timeout=13).click()
print('已点击Xlsx') print('已点击Xlsx')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_edge.ele('xpath://button[text()="下载数据"]', timeout=10).click() self.page_edge.ele('xpath://button[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
# 点击首页 获取店铺名称 # 点击首页 获取店铺名称
self.page_edge.ele('xpath://span[text()="首页"]', timeout=10).click() self.page_edge.ele('xpath://span[text()="首页"]', timeout=13).click()
print('已点击首页') print('已点击首页')
sleep(randint(5, 10)) sleep(randint(5, 10))
...@@ -298,7 +294,11 @@ class TkVideo(): ...@@ -298,7 +294,11 @@ class TkVideo():
data = self.read_excel(EXCEL_FILE) data = self.read_excel(EXCEL_FILE)
processed_data = self.process_data(data, self.shop_name) processed_data = self.process_data(data, self.shop_name)
self.store_data_in_redis(self.r, processed_data) self.store_data_in_redis(self.r, processed_data)
try:
print('删除下载文件',EXCEL_FILE)
os.remove(EXCEL_FILE)
except:
print('删除数据失败')
def send_success_message_via_wechat(self): def send_success_message_via_wechat(self):
webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL
data = { data = {
......
...@@ -89,7 +89,7 @@ class TkVideo(): ...@@ -89,7 +89,7 @@ class TkVideo():
# 等待页面初始加载 # 等待页面初始加载
time.sleep(random.randint(6, 10)) time.sleep(random.randint(6, 10))
export_orders = self.page_edge.ele('xpath://span[text()="自定义"]', timeout=10) export_orders = self.page_edge.ele('xpath://span[text()="自定义"]', timeout=13)
export_orders.click() export_orders.click()
print('点击自定义') print('点击自定义')
time.sleep(random.randint(5, 10)) time.sleep(random.randint(5, 10))
...@@ -104,11 +104,7 @@ class TkVideo(): ...@@ -104,11 +104,7 @@ class TkVideo():
print(f'已输入开始时间{self.start_year} {self.start_month} 月 {self.start_day} 日') print(f'已输入开始时间{self.start_year} {self.start_month} 月 {self.start_day} 日')
time.sleep(random.randint(3, 5)) time.sleep(random.randint(3, 5))
max_attempts = 31 for i in range(10):
while max_attempts > 0:
try: try:
xpath = ( xpath = (
f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]" f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]"
...@@ -116,7 +112,7 @@ class TkVideo(): ...@@ -116,7 +112,7 @@ class TkVideo():
f"//span[text()='{self.end_day}']/parent::div" f"//span[text()='{self.end_day}']/parent::div"
) )
print('结束日期 xpath::', xpath) print('结束日期 xpath::', xpath)
ele = self.page_edge.ele(f"xpath={xpath}", timeout=5) ele = self.page_edge.ele(f"xpath={xpath}", timeout=8)
ele.click() ele.click()
print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}') print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}')
self.get_data() self.get_data()
...@@ -137,24 +133,24 @@ class TkVideo(): ...@@ -137,24 +133,24 @@ class TkVideo():
def get_data(self): def get_data(self):
try: try:
self.page_edge.ele('xpath://div[text()="更新"]', timeout=10).click() self.page_edge.ele('xpath://div[text()="更新"]', timeout=13).click()
print('已点击更新') print('已点击更新')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_edge.ele('xpath://span[text()="下载数据"]', timeout=10).click() self.page_edge.ele('xpath://span[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_edge.ele('xpath://span[text()="Xlsx"]', timeout=10).click() self.page_edge.ele('xpath://span[text()="Xlsx"]', timeout=13).click()
print('已点击Xlsx') print('已点击Xlsx')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_edge.ele('xpath://button[text()="下载数据"]', timeout=10).click() self.page_edge.ele('xpath://button[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
# 点击首页 获取店铺名称 # 点击首页 获取店铺名称
self.page_edge.ele('xpath://span[text()="首页"]', timeout=10).click() self.page_edge.ele('xpath://span[text()="首页"]', timeout=13).click()
print('已点击首页') print('已点击首页')
sleep(randint(5, 10)) sleep(randint(5, 10))
...@@ -298,7 +294,11 @@ class TkVideo(): ...@@ -298,7 +294,11 @@ class TkVideo():
data = self.read_excel(EXCEL_FILE) data = self.read_excel(EXCEL_FILE)
processed_data = self.process_data(data, self.shop_name) processed_data = self.process_data(data, self.shop_name)
self.store_data_in_redis(self.r, processed_data) self.store_data_in_redis(self.r, processed_data)
try:
print('删除下载文件',EXCEL_FILE)
os.remove(EXCEL_FILE)
except:
print('删除数据失败')
def send_success_message_via_wechat(self): def send_success_message_via_wechat(self):
webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL
data = { data = {
......
...@@ -87,7 +87,7 @@ class TkVideo(): ...@@ -87,7 +87,7 @@ class TkVideo():
# 等待页面初始加载 # 等待页面初始加载
time.sleep(random.randint(6, 10)) time.sleep(random.randint(6, 10))
export_orders = self.page_chrome.ele('xpath://span[text()="自定义"]', timeout=10) export_orders = self.page_chrome.ele('xpath://span[text()="自定义"]', timeout=13)
export_orders.click() export_orders.click()
print('点击自定义') print('点击自定义')
time.sleep(random.randint(5, 10)) time.sleep(random.randint(5, 10))
...@@ -101,11 +101,7 @@ class TkVideo(): ...@@ -101,11 +101,7 @@ class TkVideo():
).click() ).click()
print(f'已输入开始时间{self.start_year} {self.start_month} 月 {self.start_day} 日') print(f'已输入开始时间{self.start_year} {self.start_month} 月 {self.start_day} 日')
time.sleep(random.randint(3, 5)) time.sleep(random.randint(3, 5))
for i in range(10):
max_attempts = 31
while max_attempts > 0:
try: try:
xpath = ( xpath = (
f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]" f"//div[@class='tiktok-datepicker-month-title' and contains(text(), '{self.end_year} {self.end_month} 月')]"
...@@ -113,7 +109,7 @@ class TkVideo(): ...@@ -113,7 +109,7 @@ class TkVideo():
f"//span[text()='{self.end_day}']/parent::div" f"//span[text()='{self.end_day}']/parent::div"
) )
print('结束日期 xpath::', xpath) print('结束日期 xpath::', xpath)
ele = self.page_chrome.ele(f"xpath={xpath}", timeout=5) ele = self.page_chrome.ele(f"xpath={xpath}", timeout=8)
ele.click() ele.click()
print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}') print(f'✅ 成功点击日期:{self.end_year}-{self.end_month}-{self.end_day}')
self.get_data() self.get_data()
...@@ -134,28 +130,28 @@ class TkVideo(): ...@@ -134,28 +130,28 @@ class TkVideo():
def get_data(self): def get_data(self):
try: try:
self.page_chrome.ele('xpath://div[text()="更新"]', timeout=10).click() self.page_chrome.ele('xpath://div[text()="更新"]', timeout=13).click()
print('已点击更新') print('已点击更新')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://span[text()="下载数据"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://span[text()="Xlsx"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="Xlsx"]', timeout=13).click()
print('已点击Xlsx') print('已点击Xlsx')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.page_chrome.ele('xpath://button[text()="下载数据"]', timeout=10).click() self.page_chrome.ele('xpath://button[text()="下载数据"]', timeout=13).click()
print('已点击下载数据') print('已点击下载数据')
sleep(randint(5, 10)) sleep(randint(5, 10))
# 点击首页 获取店铺名称 # 点击首页 获取店铺名称
self.page_chrome.ele('xpath://span[text()="首页"]', timeout=10).click() self.page_chrome.ele('xpath://span[text()="首页"]', timeout=13).click()
print('已点击首页') print('已点击首页')
sleep(randint(5, 10)) sleep(randint(5, 10))
self.shop_name = self.page_chrome.ele('xpath://div[@class="text-H6-Bold"]').text self.shop_name = self.page_chrome.ele('xpath://div[@class="flex items-center"]//div[@class="text-H6-Bold"]').text
print(f'已获取店铺名: {self.shop_name}') print(f'已获取店铺名: {self.shop_name}')
sleep(randint(5, 10)) sleep(randint(5, 10))
...@@ -294,7 +290,11 @@ class TkVideo(): ...@@ -294,7 +290,11 @@ class TkVideo():
data = self.read_excel(EXCEL_FILE) data = self.read_excel(EXCEL_FILE)
processed_data = self.process_data(data, self.shop_name) processed_data = self.process_data(data, self.shop_name)
self.store_data_in_redis(self.r, processed_data) self.store_data_in_redis(self.r, processed_data)
try:
print('删除下载文件',EXCEL_FILE)
os.remove(EXCEL_FILE)
except:
print('删除数据失败')
def send_success_message_via_wechat(self): def send_success_message_via_wechat(self):
webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL webhook_url = 'http://47.112.96.71:8082/selection/sendMessage' # 替换为你的企业微信机器人的Webhook URL
data = { data = {
......
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