Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python将schedule包用于webscrape_Python_Python 3.x_Web Scraping - Fatal编程技术网

如何使用python将schedule包用于webscrape

如何使用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

我编写这个脚本是为了从“Clima tempo”网站上进行一些网页抓取,我使用Beautiful soup提取信息并保存到pandas中导出到excel

但是当在代码末尾使用调度时,脚本不会自动运行

是否有任何与使用网页抓取相关的事实?这就是为什么它不起作用

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)

Perfect@AKX,非常感谢!!!!我来看看windows的任务调度程序。