Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib2
- import re
- import time
- import os
- html_content = urllib2.urlopen('https://a.4cdn.org/pol/catalog.json').read()
- trumpmatches = re.findall('TRUMP GENERAL', html_content);
- s = html_content
- programrun = 0
- while programrun == 0:
- if len(trumpmatches) == 0:
- print 'TRUMP GENERAL is NOT active'
- else:
- print 'Found at least one TRUMP GENERAL'
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page1 = find_between(s, '[{"page":1,"threads":[{"no":', ',{"page":2,')
- fpage1 = '{"page":1,"threads":[{"no":'
- fpage1 += page1
- fpage1 += '},'
- print 'P1 ' + fpage1
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page2 = find_between(s, '{"page":2,"threads":[{"no":', ',{"page":3,')
- fpage2 = '{"page":2,"threads":[{"no":'
- fpage2 += page2
- fpage2 += '},'
- print 'P2 ' + fpage2
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page3 = find_between(s, '{"page":3,"threads":[{"no":', ',{"page":4,')
- fpage3 = '{"page":3,"threads":[{"no":'
- fpage3 += page3
- fpage3 += '},'
- print 'P3 ' + fpage3
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page4 = find_between(s, '{"page":4,"threads":[{"no":', ',{"page":5,')
- fpage4 = '{"page":4,"threads":[{"no":'
- fpage4 += page4
- fpage4 += '},'
- print 'P4 ' + fpage4
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page5 = find_between(s, '{"page":5,"threads":[{"no":', ',{"page":6,')
- fpage5 = '{"page":5,"threads":[{"no":'
- fpage5 += page5
- fpage5 += '},'
- print 'P5 ' + fpage5
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page6 = find_between(s, '{"page":6,"threads":[{"no":', ',{"page":7,')
- fpage6 = '{"page":6,"threads":[{"no":'
- fpage6 += page6
- fpage6 += '},'
- print 'P6 ' + fpage6
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page7 = find_between(s, '{"page":7,"threads":[{"no":', ',{"page":8,')
- fpage7 = '{"page":7,"threads":[{"no":'
- fpage7 += page7
- fpage7 += '},'
- print 'P7 ' + fpage7
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page8 = find_between(s, '{"page":8,"threads":[{"no":', ',{"page":9,')
- fpage8 = '{"page":8,"threads":[{"no":'
- fpage8 += page8
- fpage8 += '},'
- print 'P8 ' + fpage8
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page9 = find_between(s, '{"page":9,"threads":[{"no":', ',{"page":10,')
- fpage9 = '{"page":9,"threads":[{"no":'
- fpage9 += page9
- fpage9 += '},'
- print 'P9 ' + fpage9
- def find_between(s, first, last):
- try:
- start = s.index(first) + len(first)
- end = s.index(last, start)
- return s[start:end]
- except ValueError:
- return ""
- page10 = find_between(s, '{"page":10,"threads":[{"no":', ',{"page":11,')
- fpage10 = '{"page":10,"threads":[{"no":'
- fpage10 += page10
- fpage10 += '},'
- print '10 ' + fpage10
- if 'TRUMP GENERAL' in fpage1:
- print 'TG on Page 1'
- split1 = fpage1.split('TRUMP GENERAL', 1)[0] + 'TRUMP GENERAL'
- split1 = split1.replace('{"page":1,"threads":[', '')
- compare1 = 1
- while compare1 < 23:
- def find_between(split1, first, last):
- try:
- start = split1.index(first) + len(first)
- end = split1.index(last, start)
- return split1[start:end]
- except ValueError:
- return ""
- split1compare = find_between(split1, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split1compare:
- print 'TRUMP GEN RAW ' + split1compare
- compare1 = 23
- else:
- split1 = split1.replace('{"no":"last_modified":', '')
- split1 = split1.replace(split1compare, '')
- compare1 += 1
- def find_between(split1, first, last):
- try:
- start = split1.index(first) + len(first)
- end = split1.index(last, start)
- return split1[start:end]
- except ValueError:
- return ""
- split1final = find_between(split1, '{"no":', 'TRUMP GENERAL')
- split1final = split1final[0:8]
- print 'TG thread id found: ' + split1final
- if split1final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split1final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split1final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split1final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split1final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split1final)
- text_file.close()
- print 'Wrote ' + split1final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split1final)
- text_file.close()
- print 'Wrote ' + split1final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split1final)
- text_file.close()
- print 'Wrote ' + split1final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split1final)
- text_file.close()
- print 'Wrote ' + split1final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split1final)
- text_file.close()
- print 'Wrote ' + split1final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage2:
- print 'TG on Page 2'
- split2 = fpage2.split('TRUMP GENERAL', 2)[0] + 'TRUMP GENERAL'
- split2 = split2.replace('{"page":2,"threads":[', '')
- compare2 = 1
- while compare2 < 23:
- def find_between(split2, first, last):
- try:
- start = split2.index(first) + len(first)
- end = split2.index(last, start)
- return split2[start:end]
- except ValueError:
- return ""
- split2compare = find_between(split2, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split2compare:
- print 'TRUMP GEN RAW ' + split2compare
- compare2 = 23
- else:
- split2 = split2.replace('{"no":"last_modified":', '')
- split2 = split2.replace(split2compare, '')
- compare2 += 1
- def find_between(split2, first, last):
- try:
- start = split2.index(first) + len(first)
- end = split2.index(last, start)
- return split2[start:end]
- except ValueError:
- return ""
- split2final = find_between(split2, '{"no":', 'TRUMP GENERAL')
- split2final = split2final[0:8]
- print 'TG thread id found: ' + split2final
- if split2final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split2final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split2final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split2final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split2final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split2final)
- text_file.close()
- print 'Wrote ' + split2final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split2final)
- text_file.close()
- print 'Wrote ' + split2final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split2final)
- text_file.close()
- print 'Wrote ' + split2final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split2final)
- text_file.close()
- print 'Wrote ' + split2final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split2final)
- text_file.close()
- print 'Wrote ' + split2final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage3:
- print 'TG on Page 3'
- split3 = fpage3.split('TRUMP GENERAL', 3)[0] + 'TRUMP GENERAL'
- split3 = split3.replace('{"page":3,"threads":[', '')
- compare3 = 1
- while compare3 < 23:
- def find_between(split3, first, last):
- try:
- start = split3.index(first) + len(first)
- end = split3.index(last, start)
- return split3[start:end]
- except ValueError:
- return ""
- split3compare = find_between(split3, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split3compare:
- print 'TRUMP GEN RAW ' + split3compare
- compare3 = 23
- else:
- split3 = split3.replace('{"no":"last_modified":', '')
- split3 = split3.replace(split3compare, '')
- compare3 += 1
- def find_between(split3, first, last):
- try:
- start = split3.index(first) + len(first)
- end = split3.index(last, start)
- return split3[start:end]
- except ValueError:
- return ""
- split3final = find_between(split3, '{"no":', 'TRUMP GENERAL')
- split3final = split3final[0:8]
- print 'TG thread id found: ' + split3final
- if split3final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split3final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split3final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split3final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split3final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split3final)
- text_file.close()
- print 'Wrote ' + split3final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split3final)
- text_file.close()
- print 'Wrote ' + split3final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split3final)
- text_file.close()
- print 'Wrote ' + split3final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split3final)
- text_file.close()
- print 'Wrote ' + split3final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split3final)
- text_file.close()
- print 'Wrote ' + split3final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage4:
- print 'TG on Page 4'
- split4 = fpage4.split('TRUMP GENERAL', 4)[0] + 'TRUMP GENERAL'
- split4 = split4.replace('{"page":4,"threads":[', '')
- compare4 = 1
- while compare4 < 23:
- def find_between(split4, first, last):
- try:
- start = split4.index(first) + len(first)
- end = split4.index(last, start)
- return split4[start:end]
- except ValueError:
- return ""
- split4compare = find_between(split4, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split4compare:
- print 'TRUMP GEN RAW ' + split4compare
- compare4 = 23
- else:
- split4 = split4.replace('{"no":"last_modified":', '')
- split4 = split4.replace(split4compare, '')
- compare4 += 1
- def find_between(split4, first, last):
- try:
- start = split4.index(first) + len(first)
- end = split4.index(last, start)
- return split4[start:end]
- except ValueError:
- return ""
- split4final = find_between(split4, '{"no":', 'TRUMP GENERAL')
- split4final = split4final[0:8]
- print 'TG thread id found: ' + split4final
- if split4final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split4final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split4final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split4final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split4final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split4final)
- text_file.close()
- print 'Wrote ' + split4final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split4final)
- text_file.close()
- print 'Wrote ' + split4final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split4final)
- text_file.close()
- print 'Wrote ' + split4final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split4final)
- text_file.close()
- print 'Wrote ' + split4final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split4final)
- text_file.close()
- print 'Wrote ' + split4final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage5:
- print 'TG on Page 5'
- split5 = fpage5.split('TRUMP GENERAL', 5)[0] + 'TRUMP GENERAL'
- split5 = split5.replace('{"page":5,"threads":[', '')
- compare5 = 1
- while compare5 < 23:
- def find_between(split5, first, last):
- try:
- start = split5.index(first) + len(first)
- end = split5.index(last, start)
- return split5[start:end]
- except ValueError:
- return ""
- split5compare = find_between(split5, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split5compare:
- print 'TRUMP GEN RAW ' + split5compare
- compare5 = 23
- else:
- split5 = split5.replace('{"no":"last_modified":', '')
- split5 = split5.replace(split5compare, '')
- compare5 += 1
- def find_between(split5, first, last):
- try:
- start = split5.index(first) + len(first)
- end = split5.index(last, start)
- return split5[start:end]
- except ValueError:
- return ""
- split5final = find_between(split5, '{"no":', 'TRUMP GENERAL')
- split5final = split5final[0:8]
- print 'TG thread id found: ' + split5final
- if split5final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split5final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split5final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split5final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split5final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split5final)
- text_file.close()
- print 'Wrote ' + split5final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split5final)
- text_file.close()
- print 'Wrote ' + split5final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split5final)
- text_file.close()
- print 'Wrote ' + split5final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split5final)
- text_file.close()
- print 'Wrote ' + split5final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split5final)
- text_file.close()
- print 'Wrote ' + split5final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage6:
- print 'TG on Page 6'
- split6 = fpage6.split('TRUMP GENERAL', 6)[0] + 'TRUMP GENERAL'
- split6 = split6.replace('{"page":6,"threads":[', '')
- compare6 = 1
- while compare6 < 23:
- def find_between(split6, first, last):
- try:
- start = split6.index(first) + len(first)
- end = split6.index(last, start)
- return split6[start:end]
- except ValueError:
- return ""
- split6compare = find_between(split6, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split6compare:
- print 'TRUMP GEN RAW ' + split6compare
- compare6 = 23
- else:
- split6 = split6.replace('{"no":"last_modified":', '')
- split6 = split6.replace(split6compare, '')
- compare6 += 1
- def find_between(split6, first, last):
- try:
- start = split6.index(first) + len(first)
- end = split6.index(last, start)
- return split6[start:end]
- except ValueError:
- return ""
- split6final = find_between(split6, '{"no":', 'TRUMP GENERAL')
- split6final = split6final[0:8]
- print 'TG thread id found: ' + split6final
- if split6final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split6final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split6final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split6final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split6final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split6final)
- text_file.close()
- print 'Wrote ' + split6final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split6final)
- text_file.close()
- print 'Wrote ' + split6final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split6final)
- text_file.close()
- print 'Wrote ' + split6final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split6final)
- text_file.close()
- print 'Wrote ' + split6final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split6final)
- text_file.close()
- print 'Wrote ' + split6final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage7:
- print 'TG on Page 7'
- split7 = fpage7.split('TRUMP GENERAL', 7)[0] + 'TRUMP GENERAL'
- split7 = split7.replace('{"page":7,"threads":[', '')
- compare7 = 1
- while compare7 < 23:
- def find_between(split7, first, last):
- try:
- start = split7.index(first) + len(first)
- end = split7.index(last, start)
- return split7[start:end]
- except ValueError:
- return ""
- split7compare = find_between(split7, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split7compare:
- print 'TRUMP GEN RAW ' + split7compare
- compare7 = 23
- else:
- split7 = split7.replace('{"no":"last_modified":', '')
- split7 = split7.replace(split7compare, '')
- compare7 += 1
- def find_between(split7, first, last):
- try:
- start = split7.index(first) + len(first)
- end = split7.index(last, start)
- return split7[start:end]
- except ValueError:
- return ""
- split7final = find_between(split7, '{"no":', 'TRUMP GENERAL')
- split7final = split7final[0:8]
- print 'TG thread id found: ' + split7final
- if split7final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split7final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split7final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split7final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split7final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split7final)
- text_file.close()
- print 'Wrote ' + split7final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split7final)
- text_file.close()
- print 'Wrote ' + split7final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split7final)
- text_file.close()
- print 'Wrote ' + split7final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split7final)
- text_file.close()
- print 'Wrote ' + split7final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split7final)
- text_file.close()
- print 'Wrote ' + split7final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage8:
- print 'TG on Page 8'
- split8 = fpage8.split('TRUMP GENERAL', 8)[0] + 'TRUMP GENERAL'
- split8 = split8.replace('{"page":8,"threads":[', '')
- compare8 = 1
- while compare8 < 23:
- def find_between(split8, first, last):
- try:
- start = split8.index(first) + len(first)
- end = split8.index(last, start)
- return split8[start:end]
- except ValueError:
- return ""
- split8compare = find_between(split8, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split8compare:
- print 'TRUMP GEN RAW ' + split8compare
- compare8 = 23
- else:
- split8 = split8.replace('{"no":"last_modified":', '')
- split8 = split8.replace(split8compare, '')
- compare8 += 1
- def find_between(split8, first, last):
- try:
- start = split8.index(first) + len(first)
- end = split8.index(last, start)
- return split8[start:end]
- except ValueError:
- return ""
- split8final = find_between(split8, '{"no":', 'TRUMP GENERAL')
- split8final = split8final[0:8]
- print 'TG thread id found: ' + split8final
- if split8final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split8final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split8final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split8final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split8final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split8final)
- text_file.close()
- print 'Wrote ' + split8final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split8final)
- text_file.close()
- print 'Wrote ' + split8final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split8final)
- text_file.close()
- print 'Wrote ' + split8final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split8final)
- text_file.close()
- print 'Wrote ' + split8final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split8final)
- text_file.close()
- print 'Wrote ' + split8final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage9:
- print 'TG on Page 9'
- split9 = fpage9.split('TRUMP GENERAL', 9)[0] + 'TRUMP GENERAL'
- split9 = split9.replace('{"page":9,"threads":[', '')
- compare9 = 1
- while compare9 < 23:
- def find_between(split9, first, last):
- try:
- start = split9.index(first) + len(first)
- end = split9.index(last, start)
- return split9[start:end]
- except ValueError:
- return ""
- split9compare = find_between(split9, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split9compare:
- print 'TRUMP GEN RAW ' + split9compare
- compare9 = 23
- else:
- split9 = split9.replace('{"no":"last_modified":', '')
- split9 = split9.replace(split9compare, '')
- compare9 += 1
- def find_between(split9, first, last):
- try:
- start = split9.index(first) + len(first)
- end = split9.index(last, start)
- return split9[start:end]
- except ValueError:
- return ""
- split9final = find_between(split9, '{"no":', 'TRUMP GENERAL')
- split9final = split9final[0:8]
- print 'TG thread id found: ' + split9final
- if split9final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split9final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split9final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split9final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split9final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split9final)
- text_file.close()
- print 'Wrote ' + split9final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split9final)
- text_file.close()
- print 'Wrote ' + split9final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split9final)
- text_file.close()
- print 'Wrote ' + split9final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split9final)
- text_file.close()
- print 'Wrote ' + split9final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split9final)
- text_file.close()
- print 'Wrote ' + split9final + ' to TrumpGeneral5'
- if 'TRUMP GENERAL' in fpage10:
- print 'TG on Page 10'
- split10 = fpage10.split('TRUMP GENERAL', 10)[0] + 'TRUMP GENERAL'
- split10 = split10.replace('{"page":10,"threads":[', '')
- compare10 = 1
- while compare10 < 23:
- def find_between(split10, first, last):
- try:
- start = split10.index(first) + len(first)
- end = split10.index(last, start)
- return split10[start:end]
- except ValueError:
- return ""
- split10compare = find_between(split10, '{"no":', '"last_modified"')
- if 'TRUMP GENERAL' in split10compare:
- print 'TRUMP GEN RAW ' + split10compare
- compare10 = 23
- else:
- split10 = split10.replace('{"no":"last_modified":', '')
- split10 = split10.replace(split10compare, '')
- compare10 += 1
- def find_between(split10, first, last):
- try:
- start = split10.index(first) + len(first)
- end = split10.index(last, start)
- return split10[start:end]
- except ValueError:
- return ""
- split10final = find_between(split10, '{"no":', 'TRUMP GENERAL')
- split10final = split10final[0:8]
- print 'TG thread id found: ' + split10final
- if split10final in open("C:\TrumpGeneral1.txt").read():
- print 'General already in Slot 1'
- elif split10final in open("C:\TrumpGeneral2.txt").read():
- print 'General already in Slot 2'
- elif split10final in open("C:\TrumpGeneral3.txt").read():
- print 'General already in Slot 3'
- elif split10final in open("C:\TrumpGeneral4.txt").read():
- print 'General already in Slot 4'
- elif split10final in open("C:\TrumpGeneral5.txt").read():
- print 'General already in Slot 5'
- else:
- if os.stat("C:\TrumpGeneral1.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral1.txt", "w")
- text_file.write(split10final)
- text_file.close()
- print 'Wrote ' + split10final + ' to TrumpGeneral1'
- elif os.stat("C:\TrumpGeneral2.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral2.txt", "w")
- text_file.write(split10final)
- text_file.close()
- print 'Wrote ' + split10final + ' to TrumpGeneral2'
- elif os.stat("C:\TrumpGeneral3.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral3.txt", "w")
- text_file.write(split10final)
- text_file.close()
- print 'Wrote ' + split10final + ' to TrumpGeneral3'
- elif os.stat("C:\TrumpGeneral4.txt").st_size == 0:
- text_file = open("C:\TrumpGeneral4.txt", "w")
- text_file.write(split10final)
- text_file.close()
- print 'Wrote ' + split10final + ' to TrumpGeneral4'
- else:
- text_file = open("C:\TrumpGeneral5.txt", "w")
- text_file.write(split10final)
- text_file.close()
- print 'Wrote ' + split10final + ' to TrumpGeneral5'
- print '..waiting 30 secs and looping..'
- time.sleep(30)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement