如何使用python将schedule包用于webscrape
我编写这个脚本是为了从“Clima tempo”网站上进行一些网页抓取,我使用Beautiful soup提取信息并保存到pandas中导出到excel 但是当在代码末尾使用调度时,脚本不会自动运行 是否有任何与使用网页抓取相关的事实?这就是为什么它不起作用如何使用python将schedule包用于webscrape,python,python-3.x,web-scraping,Python,Python 3.x,Web Scraping,我编写这个脚本是为了从“Clima tempo”网站上进行一些网页抓取,我使用Beautiful soup提取信息并保存到pandas中导出到excel 但是当在代码末尾使用调度时,脚本不会自动运行 是否有任何与使用网页抓取相关的事实?这就是为什么它不起作用 def extractInfo(): #Make the request html = requests.get("https://www.climatempo.com.br/previsao-do-tempo/a
def extractInfo():
#Make the request
html = requests.get("https://www.climatempo.com.br/previsao-do-tempo/agora/cidade/321/riodejaneiro-rj").content
now = BS(html, "lxml")
html = requests.get("https://www.climatempo.com.br/previsao-do-tempo/cidade/321/riodejaneiro-rj/").content
today = BS(html, "lxml")
.......
schedule.every().day.at("08:00").do(extractInfo)
while True:
schedule.run_pending()
time.sleep(1)
在这里,您可以找到github链接来检查所有脚本
脚本本身无法自动运行。这是为需要定期执行操作的长时间运行的程序设计的 根据您的操作系统,您可能需要研究
- systemd定时器/cronjobs(Linux)
- cronjobs(macOS)
- 任务计划程序(Windows)