微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

网站上有什么变化?

如何解决网站上有什么变化?

我想知道是否有一种方法可以让我监视站点的更改,而不是只收到“某些更改”的消息,我也会收到更改的消息。

我现在的代码是:

url = Request('https://stackoverflow.com',headers={'User-Agent': 'Mozilla/5.0'})
  
response = urlopen(url).read()
  
currentHash = hashlib.sha224(response).hexdigest()
print("running")
time.sleep(10)
while True:
    try:
        response = urlopen(url).read()
          
        currentHash = hashlib.sha224(response).hexdigest()
          
        time.sleep(30)
          
        response = urlopen(url).read()
          
        newHash = hashlib.sha224(response).hexdigest()
  
        if newHash == currentHash:
            continue
  
        else:
            print("something changed")
  
            response = urlopen(url).read()
  
            currentHash = hashlib.sha224(response).hexdigest()
  
            time.sleep(30)
            continue
              
    except Exception as e:
        print("error")

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。