我的脚本充当一个浏览网页的浏览器,它根据links.txt上提供的网站和所述的时间间隔进行浏览。它应该全天候提供。根据脚本的目标,有没有人看到任何可能的方法来改进代码?以下是代码:为Python Selenium定义一个无限循环,目前需要改进
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
现在的代码有什么问题?你想要改进什么? – Andersson