Created
September 4, 2018 06:39
-
-
Save alice1017/d787c2a8daf6c8d4eeab31b41f9ea266 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
from __future__ import unicode_literals | |
import time | |
import chardet | |
import hashlib | |
import requests | |
import webbrowser | |
from bs4 import BeautifulSoup | |
def hashing(body): | |
#ascii_body = body.encode("utf-8") | |
#soup = BeautifulSoup(ascii_body, "html.parser") | |
#soup.find:q | |
return hashlib.sha256(body.encode("utf-8")).hexdigest() | |
def access(url): | |
return requests.get(url) | |
def sleep(): | |
times = 10 | |
print "sleep: {0}".format(times) | |
time.sleep(times) | |
def launch_chrome(url): | |
webbrowser.open(url) | |
def main(): | |
url = "https://www.keio.co.jp/unkou/unkou_pc.html" | |
response = access(url) | |
origin_hash = hashing(response.text) | |
sleep() | |
def display(a, b): | |
print u"a: {0}".format(a) | |
print u"b: {0}".format(b) | |
while True: | |
response = access(url) | |
new_hash = hashing(response.text) | |
if origin_hash == new_hash: | |
sleep() | |
continue | |
else: | |
display(origin_hash, new_hash) | |
launch_chrome(url) | |
sleep() | |
if __name__ == "__main__": | |
try: | |
main() | |
except KeyboardInterrupt: | |
raw_input() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment