Home > Software engineering >  how to automated my selenium web scrapper?
how to automated my selenium web scrapper?

Time:12-31

I was able to write a script to scrape using selenium, right now I'm trying to automate it so it can work periodically on a server so I don't bother myself by running it from my local, I did a lot of googling but I got no clue of how I can do that, can anyone simplify things for me ..

CodePudding user response:

In order to run a python script on a linux server periodically you can make a cronjob, since you already have a python script which most probably fetches or scrapes data and saves it in a file. You can make a cronjob and set the exact time it has to run, say for instance after every 2 hours you can do it using something like this,

crontab -e

this will open a editor in your terminal, at the bottom of the text just write timing and the command to be executed.

* * * * */path/to/your/code.py

from this link you can find out how to fill out the stars https://crontab.guru/#*_*_*_*_1

if you need anymore help with using cronjobs take a look at this https://www.geeksforgeeks.org/scheduling-python-scripts-on-linux/

CodePudding user response:

i dont know if it'll really work but

while True:
    whole
    code
    here
    time.sleep(period required)

CodePudding user response:

You can simply redo your script on pythonanywhere and schedule it as a task and choose the frequency that you want the script to be executed. The current frequency options available include; script runs always, hourly or daily.

  • Related