经过测试可实现上百家店铺实时数据更新可行性方案二:
第一步:谷歌浏览器多开,将每个店铺保持登录状态不关闭,可代码建立
def create_shortcut(shipid):
target_path = r'"C:\Users\miiow\AppData\Local\Google\Chrome\Application\chrome.exe"' # 要创建快捷方式的文件路径
shortcut_name = shipid # 快捷方式的名称
shortcut_dir = r"D:\浏览器" # 快捷方式的目录
Arguments = r'--user-data-dir=D:\浏览器\{}'.format(shipid) # 添加属性值
shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortCut(os.path.join(shortcut_dir, f"{shortcut_name}.lnk"))
shortcut.TargetPath = target_path
shortcut.Arguments = Arguments
shortcut.WorkingDirectory = os.path.dirname(target_path)
shortcut.save()
# create_shortcut(352985466)
import shutil
import os
def copy_and_rename_folder(shopid):
folder_path = r"D:\浏览器\{}".format(shopid)
if not os.path.exists(folder_path):
# 示例
# source_folder = r"C:\Users\miiow\AppData\Local\Google\Chrome\User Data" # 源文件夹路径
source_folder = r"D:\浏览器\485664372" # 源文件夹路径
destination_folder = r"D:\浏览器\789_folder" # 目标文件夹路径
new_name = shopid # 新的文件夹名
# 复制文件夹
if not os.path.exists(destination_folder):
shutil.copytree(source_folder, destination_folder)
# 重命名文件夹
os.rename(destination_folder, os.path.join(os.path.dirname(destination_folder), new_name))
或者直接在谷歌快捷键属性值设置
第二步:让页面自己刷新用攻克实时监听,攻克配置时选择更新模式,就可以写进最新的数据,删除旧数据
测试开了两个浏览器
本文禁止转载或摘编