声明:这个程序就是用来逗比的,不可也无法用于商业用途!其实是我之前写的用来哄妹纸的,妹纸在大众点评卖鸡爪,每天惦记着刷点五星的好评,作为菜鸟程序猿也要好好表现啊,于是写了下面这么个深井冰的程序,妹纸开心一笑,我也就开心啦。哈哈,不过你们猜不到结局,妹纸非但不开心,还把我抓过去揍了好几顿。
因为大众点评有检测恶意刷好评的程序,所以这些好评的存在周期也就一天不到,拿来练手还是可以的。
说说我的想法:
1. 首先注册一个马甲号,使用QQ号就能注册,而且还不需要验证,So easy,抓包就能实现,不过注册的时候需要验证码,本人能力有限,把验证码下载到本地手动输入的。
2. 为了让这个马甲看起来不那么马甲,我决定完善一下马甲的资料,比如起个名字什么的,于是就需要注册成功后输入下马甲的名字,不过名字有可能已存在,还是想个不容易重复的名字吧。
3. 我还打算以后用这些小号,以后把他们级数升上去,变成带钻的,大众点评就不会删我的好评了,于是我打算把这些小号的其他资料完善一下,还是抓包实现。
4. 妹纸说,虽然你的马甲都有自己个性的名字了,不过你这马甲没有头像啊,看起来还是假假的,差评。我尝试了下,给马甲提交头像,失败告终,无颜见妹纸。
5. 最后就是找到店铺的链接进行评价啦,我是一点也不谦虚,直接都是五星,然后口味服务都是五星,但是不能让所有的马甲评论内容都一样吧?所以评论还是手动输入的。每个马甲每个店铺只能提交一次评论,而且一旦被大众点评的检测恶意好评程序删除的话只能自己看到评论了,提交评论依旧是抓包。
6. 其实我还有其他想法,比如马甲号的登陆,登陆之后去评价别的店铺,这样我的马甲就能快速升级了,不过尝试了注册那种把验证码下载到本地的方法,发现登陆不上啊,估计是时间戳的问题,好纠结,至今仍未解决。
还是直接上马吧:
1. 注册的时候把验证码存到本地
#获取注册验证码,然后手动输入验证码 def getcode(self): link = 'http://www.dianping.com/account/preg.jpg?xx=0' postdata={ 'xx':'0' } req1=urllib2.Request( link, urllib.urlencode(postdata) ) req1.add_header('Referer', 'http://www.dianping.com/account/preg.jpg?xx=0') req1.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') #req1.add_header('Cache-Control', 'no-cache') #req1.add_header('Pragma', 'no-cache') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') content = urllib2.urlopen(req1).read() with open(u'验证码/1.jpg','wb') as code: code.write(content)
#注册新用户,需要手动输入验证码,用户QQ号需要自动生成 def registerMain(self,email,vcode): url1='http://www.dianping.com/ajax/json/account/reg' postdata={ 'email':email, 'pass':'15244685623', 'vcode':vcode, 'city':'SH' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'application/json, text/javascript') req1.add_header('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8;') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/reg') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') req1.add_header('X-Request', 'JSON') req1.add_header('X-Requested-With', 'XMLHttpRequest') self.file1=urllib2.urlopen(req1).read() print self.file1
3.更改用户名
#更改用户的基本信息,用户的名字需要手动输入,其他信息也可以做成手动输入的 def updateUserInfo(self,name): url1='http://www.dianping.com/member/myinfo/setup/basic' postdata={ 'userNickName':name.decode('gb2312','ignore').encode('utf-8'), 'userSex':'1', 'userCityName':'江苏省常州市武进区常武中路801号', 'userSign':'大家好,我是一个深井冰机器人,哈哈,欢迎关注', 'operation':'update', 'currentUserSign':'大家好,我是一个深井冰机器人,哈哈,欢迎关注' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') req1.add_header('Content-Type', 'application/x-www-form-urlencoded') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/member/myinfo/setup/basic') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') self.file1=urllib2.urlopen(req1).read() #print self.file1
4. 完善用户的详细信息
#更新用户的详细信息,其实就是用来赚积分的 def userInfoDetails(self): url1='http://www.dianping.com/member/myinfo/setup/more' postdata={ 'profileBean.bodilyform':'5', 'profileBean.loveStatus':'1', 'profileBean.birthYear':'1990', 'profileBean.birthMonth':'5', 'profileBean.birthDay':'21', 'profileBean.constellation':'双子座', 'profileBean.userQQ':'234423443', 'profileBean.isQQPublic':'false', 'profileBean.userMSN':'34535455@qq.com', 'profileBean.isMsnPublic':'false', 'profileBean.job':'程序员', 'profileBean.university':'哈工大', 'profileBean.middleSchool':'长春二中', 'profileBean.personalUrl':'', 'profileBean.userHomePage':'http://blog.csdn.net/zhenyu5211314', 'profileBean.interest':'喜欢听歌,*的《米店》,赵雷《南方姑娘》', 'profileBean.movie':'喜欢葫芦娃,生活大爆炸,喜欢大话西游和彩霞仙子', 'profileBean.music':'爱杰伦,爱发哥,五月天,SHE,魏如萱,啦啦啦', 'profileBean.book':'古龙,金庸的小说,看了不少,其实最喜欢的女主角还是黄蓉', 'profileBean.dish':'东北菜啦,常州菜也不错啊,其实我很好养活的', 'operation':'update', 'bodilyformType':'1', 'currentPermaLink':'' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') req1.add_header('Content-Type', 'application/x-www-form-urlencoded') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/member/myinfo/setup/more') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') self.file1=urllib2.urlopen(req1).read() #print self.file1
5. 给店铺提交评论了
#根据店铺的URL进行评论,目前为默认评论,后期加上读取文件获得网址,手输评论和打分 def publishContent(self,content): contents = '''{"shopId":18362988,"shopType":10,"cityId":93,"star":{"title":"总体评价","value":50,"desc":"非常好"},"scoreList":[{"title":"口味","value":4,"desc":"非常好"},{"title":"环境","value":4,"desc":"非常好"},{"title":"服务","value":4,"desc":"非常好"}],"reviewBody":"'''; contents += content.decode('gb2312','ignore').encode('utf-8') contents += '''","expenseInfoList":[{"title":"人均","value":"30","desc":"元"}],"extInfoList":[{"title":"喜欢的菜","values":["鸡爪","纯手工制作","烘焙"]},{"title":"餐厅特色","values":["可送外卖","休闲小憩","随便吃吃"]}]}'''; url1='http://www.dianping.com/ajax/json/review/reviewAction' postdata={ 'run':'a', 'mode':'pro', 'info':contents, 'reviewId':'-1', 'referPage':'http://www.dianping.com/shop/18362988/review', 'sina_sync':'2', 'qzone_sync':'2', 'sohu_sync':'2' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'application/json, */*') req1.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/shop/18362988/review') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') req1.add_header('X-Request', 'JSON') req1.add_header('X-Requested-With', 'XMLHttpRequest') self.file1=urllib2.urlopen(req1).read() print self.file1
6. 更换头像,未完成
#上传用户头像,头像数据有待分析,该功能还未完成 def uploadImage(self): url='http://www.dianping.com/ajax/member/setup/userface/upload' post={ 'jump':'1c338e31d982c96ed1984a76408ea015' } req=urllib2.Request( url, urllib.urlencode(post) ) req.add_header('Accept', 'application/json, text/javascript') req.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8') req.add_header('Origin', 'http://www.dianping.com') req.add_header('Referer', 'http://www.dianping.com/member/myinfo/setup/userface') req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') req.add_header('X-Request', 'JSON') req.add_header('X-Requested-With', 'XMLHttpRequest') urllib2.urlopen(req).read() url1='http://www.dianping.com/member/myinfo/setup/userface' postdata={ 'operation':'saveUserFace', 'ut':'01c0dece0a40163fde53bfa6acb143a8cd23862ce4d42a9010634c36b3c06e546cf6b4afd5bb689d886a03fe43bfb304adcb75a89cb36054000ef1f429302ee1', 'jump':'1c338e31d982c96ed1984a76408ea015' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') req1.add_header('Content-Type', 'application/x-www-form-urlencoded') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/member/myinfo/setup/userface') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') self.file1=urllib2.urlopen(req1).read() #print self.file1
基本功能就是这样了,总体代码如下:
#-*- coding:UTF-8 -*- ''' ====================================== 此程序根据 http://www.oschina.net/code/snippet_148170_10661 内容改编 Adapted BY: zhenyu Mail:175600499@qq.com ====================================== ''' from sgmllib import SGMLParser import os,sys,urllib2,urllib,cookielib,httplib import datetime import time # 创建文件夹 path = os.getcwd() # 获取此脚本所在目录 new_path = os.path.join(path,u'验证码') if not os.path.isdir(new_path): os.mkdir(new_path) class spider(SGMLParser): def __init__(self,email,password): SGMLParser.__init__(self) self.email=email self.password=password try: cookie=cookielib.CookieJar() cookieProc=urllib2.HTTPCookieProcessor(cookie) except: raise else: opener=urllib2.build_opener(cookieProc) urllib2.install_opener(opener) #获取注册验证码,然后手动输入验证码 def getcode(self): link = 'http://www.dianping.com/account/preg.jpg?xx=0' postdata={ 'xx':'0' } req1=urllib2.Request( link, urllib.urlencode(postdata) ) req1.add_header('Referer', 'http://www.dianping.com/account/preg.jpg?xx=0') req1.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') #req1.add_header('Cache-Control', 'no-cache') #req1.add_header('Pragma', 'no-cache') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') content = urllib2.urlopen(req1).read() with open(u'验证码/1.jpg','wb') as code: code.write(content) #注册新用户,需要手动输入验证码,用户QQ号需要自动生成 def registerMain(self,email,vcode): url1='http://www.dianping.com/ajax/json/account/reg' postdata={ 'email':email, 'pass':'15244685623', 'vcode':vcode, 'city':'SH' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'application/json, text/javascript') req1.add_header('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8;') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/reg') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') req1.add_header('X-Request', 'JSON') req1.add_header('X-Requested-With', 'XMLHttpRequest') self.file1=urllib2.urlopen(req1).read() print self.file1 #根据店铺的URL进行评论,目前为默认评论,后期加上读取文件获得网址,手输评论和打分 def publishContent(self,content): contents = '''{"shopId":18362988,"shopType":10,"cityId":93,"star":{"title":"总体评价","value":50,"desc":"非常好"},"scoreList":[{"title":"口味","value":4,"desc":"非常好"},{"title":"环境","value":4,"desc":"非常好"},{"title":"服务","value":4,"desc":"非常好"}],"reviewBody":"'''; contents += content.decode('gb2312','ignore').encode('utf-8') contents += '''","expenseInfoList":[{"title":"人均","value":"30","desc":"元"}],"extInfoList":[{"title":"喜欢的菜","values":["鸡爪","纯手工制作","烘焙"]},{"title":"餐厅特色","values":["可送外卖","休闲小憩","随便吃吃"]}]}'''; url1='http://www.dianping.com/ajax/json/review/reviewAction' postdata={ 'run':'a', 'mode':'pro', 'info':contents, 'reviewId':'-1', 'referPage':'http://www.dianping.com/shop/18362988/review', 'sina_sync':'2', 'qzone_sync':'2', 'sohu_sync':'2' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'application/json, */*') req1.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/shop/18362988/review') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') req1.add_header('X-Request', 'JSON') req1.add_header('X-Requested-With', 'XMLHttpRequest') self.file1=urllib2.urlopen(req1).read() print self.file1 #更改用户的基本信息,用户的名字需要手动输入,其他信息也可以做成手动输入的 def updateUserInfo(self,name): url1='http://www.dianping.com/member/myinfo/setup/basic' postdata={ 'userNickName':name.decode('gb2312','ignore').encode('utf-8'), 'userSex':'1', 'userCityName':'江苏省常州市武进区常武中路801号', 'userSign':'大家好,我是一个深井冰机器人,哈哈,欢迎关注', 'operation':'update', 'currentUserSign':'大家好,我是一个深井冰机器人,哈哈,欢迎关注' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') req1.add_header('Content-Type', 'application/x-www-form-urlencoded') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/member/myinfo/setup/basic') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') self.file1=urllib2.urlopen(req1).read() #print self.file1 #更新用户的详细信息,其实就是用来赚积分的 def userInfoDetails(self): url1='http://www.dianping.com/member/myinfo/setup/more' postdata={ 'profileBean.bodilyform':'5', 'profileBean.loveStatus':'1', 'profileBean.birthYear':'1990', 'profileBean.birthMonth':'5', 'profileBean.birthDay':'21', 'profileBean.constellation':'双子座', 'profileBean.userQQ':'234423443', 'profileBean.isQQPublic':'false', 'profileBean.userMSN':'34535455@qq.com', 'profileBean.isMsnPublic':'false', 'profileBean.job':'程序员', 'profileBean.university':'哈工大', 'profileBean.middleSchool':'长春二中', 'profileBean.personalUrl':'', 'profileBean.userHomePage':'http://blog.csdn.net/zhenyu5211314', 'profileBean.interest':'喜欢听歌,*的《米店》,赵雷《南方姑娘》', 'profileBean.movie':'喜欢葫芦娃,生活大爆炸,喜欢大话西游和彩霞仙子', 'profileBean.music':'爱杰伦,爱发哥,五月天,SHE,魏如萱,啦啦啦', 'profileBean.book':'古龙,金庸的小说,看了不少,其实最喜欢的女主角还是黄蓉', 'profileBean.dish':'东北菜啦,常州菜也不错啊,其实我很好养活的', 'operation':'update', 'bodilyformType':'1', 'currentPermaLink':'' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') req1.add_header('Content-Type', 'application/x-www-form-urlencoded') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/member/myinfo/setup/more') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') self.file1=urllib2.urlopen(req1).read() #print self.file1 #上传用户头像,头像数据有待分析,该功能还未完成 def uploadImage(self): url='http://www.dianping.com/ajax/member/setup/userface/upload' post={ 'jump':'1c338e31d982c96ed1984a76408ea015' } req=urllib2.Request( url, urllib.urlencode(post) ) req.add_header('Accept', 'application/json, text/javascript') req.add_header('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8') req.add_header('Origin', 'http://www.dianping.com') req.add_header('Referer', 'http://www.dianping.com/member/myinfo/setup/userface') req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') req.add_header('X-Request', 'JSON') req.add_header('X-Requested-With', 'XMLHttpRequest') urllib2.urlopen(req).read() url1='http://www.dianping.com/member/myinfo/setup/userface' postdata={ 'operation':'saveUserFace', 'ut':'01c0dece0a40163fde53bfa6acb143a8cd23862ce4d42a9010634c36b3c06e546cf6b4afd5bb689d886a03fe43bfb304adcb75a89cb36054000ef1f429302ee1', 'jump':'1c338e31d982c96ed1984a76408ea015' } req1=urllib2.Request( url1, urllib.urlencode(postdata) ) req1.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') req1.add_header('Content-Type', 'application/x-www-form-urlencoded') req1.add_header('Origin', 'http://www.dianping.com') req1.add_header('Referer', 'http://www.dianping.com/member/myinfo/setup/userface') req1.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Maxthon/3.0 Chrome/22.0.1229.79 Safari/537.1') self.file1=urllib2.urlopen(req1).read() #print self.file1 renrenspider=spider('lizhenyu5211314@126.com','15244685623') #urlfile = open('canimei.txt') while(1): renrenspider.getcode() email=raw_input('请输入注册QQ号码:') vcode=raw_input('请输入验证码:') email = email + '@qq.com' renrenspider.registerMain(email,vcode) name=raw_input('请输入默认用户名:') renrenspider.updateUserInfo(name) renrenspider.userInfoDetails() #renrenspider.uploadImage() content=raw_input('Please input content:') renrenspider.publishContent(content)
最后上点程序截图还有效果图吧,不过都是没删之前的,现在评论早就被删了:
没有啦,最后希望老大生意兴隆,哈哈,有空大家也去评论下:http://www.dianping.com/shop/18362988,小弟拜谢了