检查网络抓取变量的值是否已更改的最有效方法Python,BeautifulSoup?

问题描述

我希望从网站的标签中抓取文本,首先获取所有文本,然后仅在此之后,当标签的任何文本发生更改时得到通知。使用初始空变量声明进行此无限循环是实现它的最有效方法吗?看起来很笨拙。

非常感谢您提供的任何帮助!

# Send an email with text from multiple HTML tags,then after that,ONLY send email
# when any of the tags' text has changed.

tagsOfInterest = ['tag1','tag2','tag3'] # Any tag in this list could change each scrape.



originalTags = None

while True:
    if originalTags is None:
        originalTags = []
        for tag in tagsOfInterest:
             originalTags.append(tag)
             # Email originalTags to myself
        # time.sleep(60)
    else:
        newTags = []
        for tag in tagsOfInterest:
             if tag not in originalTags:
                  newTags.append(tag)
                  # Email newTags to myself
        originalTags = newTags
        # time.sleep(60)

编辑:tagsOfInterest及其生成的请求应在while循环内。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)