Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/python
import urllib2
import re
import os
import sys
import send
import time
url = 'http://shingeki.tk/'
user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10B329 Safari/8536.25'
file_name = 'bigman.txt'
def getAllLinks():
content = urllib2.urlopen(url).read()
links = re.findall('href=\"(.*?)\"', content)
return links
def checkLinkCounters(counter):
with open(file_name, 'r') as f:
content = f.read()
if not content:
with open(file_name, 'w') as f_out:
f_out.write(str(counter))
else:
if counter != int(content):
send.send(['your@email.com', 'your@email.com'], 'Big man is coming', url)
os._exit(1)
def main():
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', user_agent)]
urllib2.install_opener(opener)
pid = os.fork()
if pid == 0:
sys.exit()
else:
while True:
links = getAllLinks()
checkLinkCounters(len(links))
time.sleep(30)
if __name__ == '__main__' :
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.