1

Good afternoon,

I have an issue. I'm a starter python programmer and for one of my clients for which I make very high-level spreadsheets I wrote a python script that uses selenium webdriver to obtain a data file from a website. However, this file has to run every morning at 7:00 and I would like to know if there is any way to keep this script running 24/7 so that it can perform it's tasking every morning at 7:00. Optionally I have a raspberry pi 4 to use however I have never used it for anything so far it is still boxed.

Thanks in advance.

Sincerely,

Thomas

3 Answers 3

1

You can simply use crontab

0 7 * * * yourScriptCommand
Sign up to request clarification or add additional context in comments.

1 Comment

So you are suggesting that I run a linux based operating system on my raspberry pi and use crontab to make the raspberry pi run the script every day at 07:00?
1

You can look into renting a cheapish cloud server (from digitalocean for example). There are multiple ways of transferring data from your python script to your bot, either directly, through a websocket, or a webpage that displays it in a JSON format or otherwise.

Since you're already using python you could look into running a flask app on your node alongside your script or even combine them together.

If ran separately you could modify your script to output it's content into a file and then read the file with your flask application to display it on a webpage. For example:

with open('/tmp/data.txt', 'w') as f:
f.write(yourdata)

then in your flask application:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def show_data():
with open('/tmp/data.txt', 'r') as f:
    data = f.read()
return data

1 Comment

The data comes from downloading a file from a site, so it requires 'clicking' a download button to get the file. Then it transfers the file to a folder. Reads it with pandas and uploads it to a spreadsheet in google using gspread. Is it possible to download such a file with like a http request or with bs4?
0

Thomas, i think, that for your script will running 24/7 you can use web host(PythonAnyWhere(he's free)), and that for your script make some tasks in 7:00 o'clock, you can make condition in your script with datetime module. make loop while for that your script to be pending, kinda this:

while(time != 7:00): 
    pass 
    if time == 7:00:
        do something

3 Comments

The problem I have is that my script has a selenium webdriver. Which requires a version of chrome driver to be launched and to visit a web page. I don't think web host's support that
I'm not sure, but for that you can search in google for more info.
PythonAnywhere does support Selenium, but with a free account you'd be limited to accessing sites on a whitelist (pythonanywhere.com/whitelist), so you'd need to use a paid account to scrape any sites that are not on that list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.