-1

My script serves as a web browser that is browsing the net according to the website provided on links.txt and the time interval stated. It should be available 24/7. Does anybody see any possible way to improve the code according to the goal of the script? The following is the code:

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
R.DL
  • 3
  • 1
  • 3

1 Answers1

0

Even when your code is running It is possible to the computer to get locked, because It does not recognize your program's actions as a person action. All you need to do to get it 24/7 is change your PC's configs so It won't lock in 15min.

I had this thinking and I had my mac to shut after 5 min, even with my selenium opening browsers and doing many actions It would lock the screen. It doesn't need to have any problem, It's just not reseting the locker timer cause to the computer your program is just another process running.

If you have anything else to ask, this or this posts must help you out.

Community
  • 1
  • 1
Arthur Silva
  • 150
  • 1
  • 2
  • 11
  • The code above is actually an updated version of the code that I had before. I asked this question because I hadn't run the script above as yet, and I wanted to find any errors if possible.Currently the script above has been running fine for the past 3 days. The screen doesn't lock down due to the line: pyautogui.press('f15') The f15 key isn't present on a normal keyboard; however the computer recognizes it as human behavior and continues to run. Before this I tried to change my PC configs, but on a corporate environment it's impossible to do so unless IT gives permission. – R.DL Mar 04 '16 at 09:38
  • Sorry for not making it clear that this was an updated code to the version before. – R.DL Mar 04 '16 at 09:41