本文介绍了如何每天在任何地方使用免费的在线服务器(如python)在每天的同一时间运行python脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从这个视频中得到了这个主意,但我意识到我制作的脚本涉及硒和硒所需的铬驱动器.我需要每天午夜左右运行脚本.我该如何解决?任何帮助表示赞赏.谢谢

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上运行脚本,则可以购买树莓派,并让它为您完成此任务(通过创建一个Shell脚本来安排脚本运行时间),或者您可以选择将脚本托管在云中,但是与使用个人设备相比,您需要支付更多的费用.

If you don't want to run the script from your PC, you can buy a raspberry pi and let it do this job for your (by making creating a shell script to schedule script running), or you can opt-in to host your script in cloud, but you will need to pay more than if you would use a personal device.

这篇关于如何每天在任何地方使用免费的在线服务器(如python)在每天的同一时间运行python脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 07:48