# -*- coding:utf-8 -*-
import urllib
import urllib2
import re
import sys
import time
import threading
OUTPUT_ENCODE = 'shift-jis'
YAHOO_ENCODE = 'utf-8'
POLLING_PAGE = 'http://v...content-available-to-author-only...o.jp/theme/106'
POSTURL = 'http://v...content-available-to-author-only...o.jp/poll'
UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7'
INTERVAL = 1
def GetCookie():
header = {'User-Agent':UA}
req = urllib2.Request(POLLING_PAGE,None,header)
res = urllib2.urlopen(req)
cookie = res.info()['Set-Cookie'].split(';')[0]
return cookie
def GetCrumb(cookie):
term = ur'<input type="hidden" name="crumb" value=".*">'
header = {
'User-Agent':UA,
'Cookie':cookie
}
req = urllib2.Request(POLLING_PAGE,None,header)
res = urllib2.urlopen(req)
html = res.read().decode(YAHOO_ENCODE)
m = re.search(term,html)
if(m is None):
print(u'しばらくたってからまた来てね☆'.encode(OUTPUT_ENCODE))
return None
return m.group(0)[41:-2]
def Postyahoo(cookie):
crumb = GetCrumb(cookie)
if(crumb is None):
return
header = {'Cookie':cookie}
data = {
"pollChoice[]":'9',
"pollId":'16',
"pageId":'106',
"pageType":'theme',
"page":'1',
"crumb":crumb,
'submit':u'投票する'.encode(YAHOO_ENCODE)
}
data = urllib.urlencode(data)
req = urllib2.Request(POSTURL, data, header)
res = urllib2.urlopen(req)
if(u'投票ありがとうございました' in res.read().decode(YAHOO_ENCODE)):
print(u'投票完了'.encode(OUTPUT_ENCODE))
else:
print(u'何かがおかしい'.encode(OUTPUT_ENCODE))
def post():
while(True):
cookie = GetCookie()
Postyahoo(cookie)
time.sleep(INTERVAL)
def main():
print('PLEASE USE THIS PROGRAM AT YOUR OWN RISK.')
threadnum = 0
interv = 0
try:
threadnum = int(raw_input(u'スレッドを立てる数を入力(よく分からなければそのままEnter):'.encode(OUTPUT_ENCODE)))
except ValueError:
threadnum = 1
try:
interv = int(raw_input(u'投稿間隔を入力(sec):'.encode(OUTPUT_ENCODE)))
except ValueError:
interv = 1
INTERVAL = interv
tlst = []
for i in range(threadnum):
tlst.append(threading.Thread(target=post))
for i in tlst:
i.start()
if __name__ == '__main__':
main()
IyAtKi0gY29kaW5nOnV0Zi04IC0qLQoKaW1wb3J0IHVybGxpYgppbXBvcnQgdXJsbGliMgppbXBvcnQgcmUKaW1wb3J0IHN5cwppbXBvcnQgdGltZQppbXBvcnQgdGhyZWFkaW5nCgpPVVRQVVRfRU5DT0RFID0gJ3NoaWZ0LWppcycKWUFIT09fRU5DT0RFID0gJ3V0Zi04JwpQT0xMSU5HX1BBR0UgPSAnaHR0cDovL3YuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLm8uanAvdGhlbWUvMTA2JwpQT1NUVVJMID0gJ2h0dHA6Ly92Li4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5vLmpwL3BvbGwnClVBID0gJ01vemlsbGEvNS4wIChXaW5kb3dzIE5UIDYuMTsgV09XNjQpIEFwcGxlV2ViS2l0LzUzNS43IChLSFRNTCwgbGlrZSBHZWNrbykgQ2hyb21lLzE2LjAuOTEyLjc1IFNhZmFyaS81MzUuNycKSU5URVJWQUwgPSAxCgpkZWYgR2V0Q29va2llKCk6CiAgICBoZWFkZXIgPSB7J1VzZXItQWdlbnQnOlVBfQogICAgcmVxID0gdXJsbGliMi5SZXF1ZXN0KFBPTExJTkdfUEFHRSxOb25lLGhlYWRlcikKICAgIHJlcyA9IHVybGxpYjIudXJsb3BlbihyZXEpCiAgICBjb29raWUgPSByZXMuaW5mbygpWydTZXQtQ29va2llJ10uc3BsaXQoJzsnKVswXQogICAgcmV0dXJuIGNvb2tpZQoKZGVmIEdldENydW1iKGNvb2tpZSk6CiAgICB0ZXJtID0gdXInPGlucHV0IHR5cGU9ImhpZGRlbiIgbmFtZT0iY3J1bWIiIHZhbHVlPSIuKiI+JwoKICAgIGhlYWRlciA9IHsKICAgICAgICAnVXNlci1BZ2VudCc6VUEsCiAgICAgICAgJ0Nvb2tpZSc6Y29va2llCiAgICB9CiAgICByZXEgPSB1cmxsaWIyLlJlcXVlc3QoUE9MTElOR19QQUdFLE5vbmUsaGVhZGVyKQogICAgcmVzID0gdXJsbGliMi51cmxvcGVuKHJlcSkKICAgIGh0bWwgPSByZXMucmVhZCgpLmRlY29kZShZQUhPT19FTkNPREUpCiAgICBtID0gcmUuc2VhcmNoKHRlcm0saHRtbCkKICAgIGlmKG0gaXMgTm9uZSk6CiAgICAgICAgcHJpbnQodSfjgZfjgbDjgonjgY/jgZ/jgaPjgabjgYvjgonjgb7jgZ/mnaXjgabjga3imIYnLmVuY29kZShPVVRQVVRfRU5DT0RFKSkKICAgICAgICByZXR1cm4gTm9uZQogICAgcmV0dXJuIG0uZ3JvdXAoMClbNDE6LTJdCgpkZWYgUG9zdHlhaG9vKGNvb2tpZSk6CiAgICBjcnVtYiA9IEdldENydW1iKGNvb2tpZSkKICAgIGlmKGNydW1iIGlzIE5vbmUpOgogICAgICAgIHJldHVybgoKICAgIGhlYWRlciA9IHsnQ29va2llJzpjb29raWV9CiAgICBkYXRhID0gewogICAgICAgICJwb2xsQ2hvaWNlW10iOic5JywKICAgICAgICAicG9sbElkIjonMTYnLAogICAgICAgICJwYWdlSWQiOicxMDYnLAogICAgICAgICJwYWdlVHlwZSI6J3RoZW1lJywKICAgICAgICAicGFnZSI6JzEnLAogICAgICAgICJjcnVtYiI6Y3J1bWIsCiAgICAgICAgJ3N1Ym1pdCc6dSfmipXnpajjgZnjgosnLmVuY29kZShZQUhPT19FTkNPREUpCiAgICB9CiAgICBkYXRhID0gdXJsbGliLnVybGVuY29kZShkYXRhKQogICAgcmVxID0gdXJsbGliMi5SZXF1ZXN0KFBPU1RVUkwsIGRhdGEsIGhlYWRlcikKICAgIHJlcyA9IHVybGxpYjIudXJsb3BlbihyZXEpCiAgICBpZih1J+aKleelqOOBguOCiuOBjOOBqOOBhuOBlOOBluOBhOOBvuOBl+O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3IgaSBpbiB0bHN0OgogICAgICAgIGkuc3RhcnQoKQoKaWYgX19uYW1lX18gPT0gJ19fbWFpbl9fJzoKICAgIG1haW4oKQo=
PLEASE USE THIS PROGRAM AT YOUR OWN RISK.
�X���b�h�𗧂Ă鐔���(�悭������Ȃ�����̂܂�Enter):
Traceback (most recent call last):
File "prog.py", line 90, in <module>
File "prog.py", line 74, in main
EOFError: EOF when reading a line