简体   繁体   中英

How to use free online servers like python anywhere to run python script at the same time every day?

I got the idea from this video but I realized the script I made involves selenium and the chrome driver required for selenium. I need to run the script around midnight everyday. How do I work around this? Any help is appreciated. Thanks

from selenium import webdriver
import datetime

PATH = "C:/Users/abhin/Downloads/Selenium drivers/chromedriver.exe"

driver = webdriver.Chrome(PATH)
driver.get('XXXXX')

user = "XXXXX"
password = "XXXXX"
number = "XXXXX"
purpose = "XXXXX"
dep = "XXXXX"

today = datetime.date.today()
bkDate = today
bkDate_new = bkDate.strftime("%a, %d-%m-%Y")
bkDateNum = bkDate.strftime("%d")

user_textbox = driver.find_element_by_id("j_username")
user_textbox.send_keys(user)

password_textbox = driver.find_element_by_id("j_password")
password_textbox.send_keys(password)

login_button = driver.find_element_by_css_selector("input.form-button")
login_button.click()

driver.get("https://XXXXX")

number_textbox = driver.find_element_by_id("contact_no")
number_textbox.send_keys(number)

purpose_textbox = driver.find_element_by_id("purpose")
purpose_textbox.send_keys(purpose)

slot1 = driver.find_element_by_xpath("/html/body/div[2]/div[1]/div/div[2]/main/div[1]/fieldset/form/div[8]/div[2]/div[2]/div[1]/label[1]")
slot1.click()

submit_btn = driver.find_element_by_xpath("/html/body/div[2]/div[1]/div/div[2]/main/div[1]/fieldset/form/div[10]/div[2]/div/i/input")
submit_btn.click()

如果您不想从您的 PC 运行脚本,您可以购买一个 raspberry pi 并让它为您完成这项工作(通过创建一个 shell 脚本来安排脚本运行),或者您可以选择托管您的云中的脚本,但与使用个人设备相比,您需要支付更多费用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM