我的脚本用作网络浏览器,根据 links.txt 上提供的网站和规定的时间间隔浏览网络。它应该 24/7 可用。有没有人看到任何可能的方法来根据脚本的目标改进代码?以下是代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pyautogui
import time
import os.path as path
import sys
def runlinks(f):
for line in f:
key, val = line.split(";")
driver.get(key)
pyautogui.moveTo(5000, None)
time.sleep(int(val))
pyautogui.press('f15')
return()
driver = webdriver.Firefox()
pyautogui.press('f11')
count = 0
infile = "Z:\Full-Route\links.txt" #This is your links's file Path
while count < 1:
try:
with open(infile, "r") as f:
runlinks(f)
except:
pass