ข้อความเดียวกันเพิ่ม ... ให้แตกต่าง random ข้อความ 1 ถึง 4 comment ได้บ้างไม่ได้บ้าง
ERROR!
Some of the content in your message is not permitted by hi5. If you have any questions, please visit our FAQ page.
comment ไปสักพักขึ้น
ERROR!
Sorry. you have sent the maximum number of profile comments allowed in a given period.
Source Code "hi5 auto comment" ภาษา python ปัจจุบันผู้พัฒนา (zen.in.th) เลิกพัฒนาแล้ว
###Author: Phuriphat Boontanon (Do not delete this credit)###
import urllib, urllib2, cookielib, getpass, re, socket, time, sys
from urllib2 import URLError, HTTPError
from threading import Timer
#-*- encoding: utf-8 -*-
####Set default timeout####
timeout = 45
socket.setdefaulttimeout(timeout)
###Declare browse###
cj = cookielib.CookieJar()
browse = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
###Close socket###
def close_sock(toclose):
toclose.close()
###Login###
first_time_active = 1
eptemp = 0
def login():
global first_time_active, eptemp, browse, URLError
if(first_time_active == 1):
msgemail = "Input your email: "
msgpassword = "Then enter your password please: "
else:
msgemail = "Input your email again: "
msgpassword = "Then enter your password again please: "
email = raw_input(msgemail)
print "OK. your email is: ".strip() + " " + email
password = getpass.getpass(msgpassword)
eptemp = urllib.urlencode({'email': email, 'password': password})
url = 'http://www.hi5.com/friend/login.do?'.strip() + eptemp
###Reach to server###
try:
loginpage = browse.open(url, eptemp)
###If get HTTPError###
except URLError, e:
if hasattr(e, 'reason'):
print 'Failed to reach a server.'
print 'Reason: ', e.reason
first_time_active = 0
login()
elif hasattr(e, 'code'):
print 'The server couldn't fulfill the request.'
print 'Error code: ', e.code
first_time_active = 0
login()
###If Fine###
else:
###Login successful###
loginstatus = re.findall('Message-Error', loginpage.read())
if len(loginstatus):
print "Login failed\nThis means your email or password is wrong or hi5 is down."
first_time_active = 0
login()
###Wrong password or something###
else:
print "Login successful"
return eptemp
###Get friends###
def get_friends(alphabet):
url = 'http://www.hi5.com/friend/viewFriends.do?limit=10000&alphabet='.strip() + alphabet
friends_data = browse.open(url, eptemp).read()
friends = re.findall('<a href="/friend/p([0-9]+)--(.*?)--html">', friends_data)
return friends
###Commenting###
work_count = 0
def comment(text, fdata):
global work_count, URLError, browse
if work_count == 400:
return 1
url = 'http://www.hi5.com/friend/book/displayBook.do?userid='.strip() + fdata[0]
try:
cmpage = browse.open(url, eptemp).read()
###If get HTTPError###
except URLError, e:
if hasattr(e, 'reason'):
print 'We failed to reach a server.'
print 'Reason: ', e.reason
elif hasattr(e, 'code'):
print 'The server couldn't fulfill the request.'
print 'Error code: ', e.code
###If Fine###
else:
print "Comment to".strip() + " " + fdata[1] + " [" + fdata[0] + "]"
if re.findall('name="timestamp" value="(.*?)"', cmpage):
timestamp = re.findall('name="timestamp" value="(.*?)"', cmpage)[0]
js = re.findall('name="js" value="(.*?)"', cmpage)[0]
params = urllib.urlencode({'body': text, 'timestamp': timestamp, 'js': js, 'userid': fdata[0], 'userId': fdata[0]})
url = 'http://www.hi5.com/friend/book/addProfileComment.do'
try:
comment = browse.open(url, params)
timer = Timer(35.0, close_sock, [comment])
timer.start()
###If get HTTPError###
except URLError, e:
if hasattr(e, 'reason'):
print 'Failed to reach a server.'
print 'Reason: ', e.reason
elif hasattr(e, 'code'):
print 'The server couldn't fulfill the request.'
print 'Error code: ', e.code
###If Fine###
else:
status = comment.geturl()
timer.cancel()
if "type=success" in status:
print "***Commented***"
work_count = work_count + 1
#print work_count
elif "type=approval" in status:
print "+++Unapproval+++"
work_count = work_count + 1
#print work_count
else:
print "---Failed---"
###HelloWorld###
print "****Autocomment Hi5 (beta)****"
print "by Zenn [@nneztw, z.t@live.jp, pb13110@gmail.com]"
raw_input("Press enter to continue")
###Login###
eptemp = login()
def str_int(text):
sum = 0
lent = len(text)-1
for sti in range(lent, -1, -1):
sum = sum + (ord(text[sti]) - ord('0'))*(pow(10, lent-sti))
return sum
###Resume Check###
resumeCheck = open("resume.txt", "r").read()
resumeCheck = re.findall('\[(.*?)\]', resumeCheck)
resumeActive = 1
for rsi in range(0, len(resumeCheck)):
resumeCheck[rsi] = str_int(resumeCheck[rsi])
startAlpha = 0
startOffset = 0
if resumeCheck[0] == 0:
resumeActive = 0
else:
resumeAccept = raw_input("RESUME!! [Continue?] y/n: ")
if resumeAccept == 'y':
startAlpha = resumeCheck[1]
startOffset = resumeCheck[2]
elif resumeAccept == 'Y':
startAlpha = resumeCheck[1]
startOffset = resumeCheck[2]
else:
resumeActive = 0
resumeFile = open("resume.txt", "w")
resumeFile.write("[0]")
resumeFile.close()
###Comment Section###
for i in range(startAlpha, 28):
if(i == 26):
alphabet = 'th'
elif(i == 27):
alphabet = 'other'
else:
alphabet = chr(ord('a')+i)
friends = get_friends(alphabet)
found = 0
if resumeActive == 1:
found = "%s %s %s %ld %s"%("Continue at ", alphabet, " and found ", len(friends)/2, " persons")
resumeActive = 0
else:
found = "%s %s %ld %s"%("Found", alphabet, len(friends)/2, "persons")
startOffset = 0
print found
###Start commenting###
friendsCount = len(friends)
for j in range(startOffset, friendsCount, 2):
text = open("comment.txt", "r").read()
###Remove Links from Comment###
linksIn = re.findall('((.*?)</a>)', text)
linksInCount = len(linksIn)
for k in range(0, linksInCount):
text = text.replace(linksIn[k][0], linksIn[k][2])
text = text.replace("$name", friends[j][1])
text = '
<div class="zninth">'.strip() + text + '\n</div>
'
commentStatus = comment(text, friends[j])
resumeOpen = open("resume.txt", "w")
if j+2 < friendsCount:
j = j+2
else:
j = 0
i = i + 1
toWrite = "[1][%d][%d]"%(i, j)
resumeOpen.write(toWrite)
resumeOpen.close()
if commentStatus == 1:
sys.exit(0)
time.sleep(1.5)
ERROR!
Some of the content in your message is not permitted by hi5. If you have any questions, please visit our FAQ page.
comment ไปสักพักขึ้น
ERROR!
Sorry. you have sent the maximum number of profile comments allowed in a given period.
Source Code "hi5 auto comment" ภาษา python ปัจจุบันผู้พัฒนา (zen.in.th) เลิกพัฒนาแล้ว
###Author: Phuriphat Boontanon (Do not delete this credit)###
import urllib, urllib2, cookielib, getpass, re, socket, time, sys
from urllib2 import URLError, HTTPError
from threading import Timer
#-*- encoding: utf-8 -*-
####Set default timeout####
timeout = 45
socket.setdefaulttimeout(timeout)
###Declare browse###
cj = cookielib.CookieJar()
browse = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
###Close socket###
def close_sock(toclose):
toclose.close()
###Login###
first_time_active = 1
eptemp = 0
def login():
global first_time_active, eptemp, browse, URLError
if(first_time_active == 1):
msgemail = "Input your email: "
msgpassword = "Then enter your password please: "
else:
msgemail = "Input your email again: "
msgpassword = "Then enter your password again please: "
email = raw_input(msgemail)
print "OK. your email is: ".strip() + " " + email
password = getpass.getpass(msgpassword)
eptemp = urllib.urlencode({'email': email, 'password': password})
url = 'http://www.hi5.com/friend/login.do?'.strip() + eptemp
###Reach to server###
try:
loginpage = browse.open(url, eptemp)
###If get HTTPError###
except URLError, e:
if hasattr(e, 'reason'):
print 'Failed to reach a server.'
print 'Reason: ', e.reason
first_time_active = 0
login()
elif hasattr(e, 'code'):
print 'The server couldn't fulfill the request.'
print 'Error code: ', e.code
first_time_active = 0
login()
###If Fine###
else:
###Login successful###
loginstatus = re.findall('Message-Error', loginpage.read())
if len(loginstatus):
print "Login failed\nThis means your email or password is wrong or hi5 is down."
first_time_active = 0
login()
###Wrong password or something###
else:
print "Login successful"
return eptemp
###Get friends###
def get_friends(alphabet):
url = 'http://www.hi5.com/friend/viewFriends.do?limit=10000&alphabet='.strip() + alphabet
friends_data = browse.open(url, eptemp).read()
friends = re.findall('<a href="/friend/p([0-9]+)--(.*?)--html">', friends_data)
return friends
###Commenting###
work_count = 0
def comment(text, fdata):
global work_count, URLError, browse
if work_count == 400:
return 1
url = 'http://www.hi5.com/friend/book/displayBook.do?userid='.strip() + fdata[0]
try:
cmpage = browse.open(url, eptemp).read()
###If get HTTPError###
except URLError, e:
if hasattr(e, 'reason'):
print 'We failed to reach a server.'
print 'Reason: ', e.reason
elif hasattr(e, 'code'):
print 'The server couldn't fulfill the request.'
print 'Error code: ', e.code
###If Fine###
else:
print "Comment to".strip() + " " + fdata[1] + " [" + fdata[0] + "]"
if re.findall('name="timestamp" value="(.*?)"', cmpage):
timestamp = re.findall('name="timestamp" value="(.*?)"', cmpage)[0]
js = re.findall('name="js" value="(.*?)"', cmpage)[0]
params = urllib.urlencode({'body': text, 'timestamp': timestamp, 'js': js, 'userid': fdata[0], 'userId': fdata[0]})
url = 'http://www.hi5.com/friend/book/addProfileComment.do'
try:
comment = browse.open(url, params)
timer = Timer(35.0, close_sock, [comment])
timer.start()
###If get HTTPError###
except URLError, e:
if hasattr(e, 'reason'):
print 'Failed to reach a server.'
print 'Reason: ', e.reason
elif hasattr(e, 'code'):
print 'The server couldn't fulfill the request.'
print 'Error code: ', e.code
###If Fine###
else:
status = comment.geturl()
timer.cancel()
if "type=success" in status:
print "***Commented***"
work_count = work_count + 1
#print work_count
elif "type=approval" in status:
print "+++Unapproval+++"
work_count = work_count + 1
#print work_count
else:
print "---Failed---"
###HelloWorld###
print "****Autocomment Hi5 (beta)****"
print "by Zenn [@nneztw, z.t@live.jp, pb13110@gmail.com]"
raw_input("Press enter to continue")
###Login###
eptemp = login()
def str_int(text):
sum = 0
lent = len(text)-1
for sti in range(lent, -1, -1):
sum = sum + (ord(text[sti]) - ord('0'))*(pow(10, lent-sti))
return sum
###Resume Check###
resumeCheck = open("resume.txt", "r").read()
resumeCheck = re.findall('\[(.*?)\]', resumeCheck)
resumeActive = 1
for rsi in range(0, len(resumeCheck)):
resumeCheck[rsi] = str_int(resumeCheck[rsi])
startAlpha = 0
startOffset = 0
if resumeCheck[0] == 0:
resumeActive = 0
else:
resumeAccept = raw_input("RESUME!! [Continue?] y/n: ")
if resumeAccept == 'y':
startAlpha = resumeCheck[1]
startOffset = resumeCheck[2]
elif resumeAccept == 'Y':
startAlpha = resumeCheck[1]
startOffset = resumeCheck[2]
else:
resumeActive = 0
resumeFile = open("resume.txt", "w")
resumeFile.write("[0]")
resumeFile.close()
###Comment Section###
for i in range(startAlpha, 28):
if(i == 26):
alphabet = 'th'
elif(i == 27):
alphabet = 'other'
else:
alphabet = chr(ord('a')+i)
friends = get_friends(alphabet)
found = 0
if resumeActive == 1:
found = "%s %s %s %ld %s"%("Continue at ", alphabet, " and found ", len(friends)/2, " persons")
resumeActive = 0
else:
found = "%s %s %ld %s"%("Found", alphabet, len(friends)/2, "persons")
startOffset = 0
print found
###Start commenting###
friendsCount = len(friends)
for j in range(startOffset, friendsCount, 2):
text = open("comment.txt", "r").read()
###Remove Links from Comment###
linksIn = re.findall('((.*?)</a>)', text)
linksInCount = len(linksIn)
for k in range(0, linksInCount):
text = text.replace(linksIn[k][0], linksIn[k][2])
text = text.replace("$name", friends[j][1])
text = '
<div class="zninth">'.strip() + text + '\n</div>
'
commentStatus = comment(text, friends[j])
resumeOpen = open("resume.txt", "w")
if j+2 < friendsCount:
j = j+2
else:
j = 0
i = i + 1
toWrite = "[1][%d][%d]"%(i, j)
resumeOpen.write(toWrite)
resumeOpen.close()
if commentStatus == 1:
sys.exit(0)
time.sleep(1.5)