严格来讲是给在OSC上贡献过内容的OSC用户刷积分。
OSC很多操作都需要消耗积分,很多人给OSC贡献了内容,
但是却没有人点赞,所以有些人在OSC混了很多年也没有积分。
本文中使用到的工具有gifcam 、fiddler 、Wireshark。gifcam 是一个小巧的GIF录屏软件,可以把你电脑上的操作录成GIF动图。
fiddler是一个专注于http抓包的工具,Wireshark知名网络抓包工具.
使用到的第三方python库有requests,非常好用的http库.
tqdm 是一个字符界面的进度条库,用来显示一个进度条.
以下给OSC代码频道点赞的HTTP抓包:
POST http://www.oschina.net/action/code/vote?user=96078&id=56399&vote=true HTTP/1.1
Host: www.oschina.net
Connection: keep-alive
Content-Length: 0
Accept: */*
Origin: http://www.oschina.net
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
DNT: 1
Referer: http://www.oschina.net/code/snippet_2294527_56399
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.8,en;q=0.6
Cookie: aliyungf_tc=AQAAAPQVanIYog4AcqTY3miEpBuE23as; oscid=E6bU16Ju1HvE6Yzbnu8glj%2F9WLxOYWRWYxXAtsj0Aej07gXXkM40x8fUrYQQC%2BjMrW1%2FQHYHaASCi3mDoeDQrJ%2Bp%2B5Osd1yhR737Ok7o%2BpTQTh4UQ6bITg%3D%3D
给代码频道刷积分的python代码:
"""
2016年5月24日 09:06:46 codegay
进度条库tqdm 的github地址:
https://github.com/noamraph/tqdm
"""
from requests import post
from tqdm import trange
from time import sleep
#tqdm是一个字符界面的进度条库
#安装命令pip install tqdm
httphead={'Accept':'*/*',
'Origin':'http://www.oschina.net',
'X-Requested-With':'XMLHttpRequest',
'User-Agent':'Safari/537.36',
'DNT':'1',
'Referer':'http://www.oschina.net/code/snippet_2294527_56399',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6',
}
cookie={'aliyungf_tc':'AQAAAPQVanIYog4AcqTY3miEpBuE23as',
'oscid':'E6bU16Ju1HvE6Yzbnu8glj%2F9WLxOYWRWYxXAtsj0Aej07gXXkM40x8fUrYQQC%2BjMrW1%2FQHYHaASCi3mDoeDQrJ%2Bp%2B5Osd1yhR737Ok7o%2BpTQTh4UQ6bITg%3D%3D',
}
url='http://www.oschina.net/action/code/vote?user=96078&id={0}&vote=true'
for r in trange(56422,1,-1):
try:
post(url.format(r),headers=httphead,cookies=cookie)
sleep(0.1)
except:
pass
以下是fiddler 给翻译段落点赞的抓包:
POST http://www.oschina.net/action/translate/vote_block HTTP/1.1
Host: www.oschina.net
Connection: keep-alive
Content-Length: 19
Accept: */*
Origin: http://www.oschina.net
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36
Content-Type: application/x-www-form-urlencoded
DNT: 1
Referer: http://www.oschina.net/translate/use-open-source-to-hone-your-programming-skills
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.8,en;q=0.6
Cookie: aliyungf_tc=AQAAAPQVanIYog4AcqTY3miEpBuE23as; oscid=E6bU16Ju1HvE6Yzbnu8glj%2F9WLxOYWRWYxXAtsj0Aej07gXXkM40x8fUrYQQC%2BjMrW1%2FQHYHaASCi3mDoeDQrJ%2Bp%2B5Osd1yhR737Ok7o%2BpTQTh4UQ6bITg%3D%3D
id=50710&user=96078
以下python代码是给osc贡献翻译的段落点赞:
"""
2016年5月24日 09:06:46 codegay
进度条库tqdm 的github地址:
https://github.com/noamraph/tqdm
"""
from requests import post
from tqdm import trange
from os import system
from time import sleep
system("title 给所有的翻译刷段落积分~")
system("date /t&time /t&echo 积分刷起来~~~")
print()
#tqdm是一个字符界面的进度条库
#安装命令pip install tqdm
httphead={'Accept':'*/*',
'Origin':'http://www.oschina.net',
'X-Requested-With':'XMLHttpRequest',
'User-Agent':'Safari/537.36',
'DNT':'1',
'Referer':'http://www.oschina.net/translate/use-open-source-to-hone-your-programming-skills',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6',
'Content-Type':'application/x-www-form-urlencoded',
}
cookie={'aliyungf_tc':'AQAAAPQVanIYog4AcqTY3miEpBuE23as',
'oscid':'E6bU16Ju1HvE6Yzbnu8glj%2F9WLxOYWRWYxXAtsj0Aej07gXXkM40x8fUrYQQC%2BjMrW1%2FQHYHaASCi3mDoeDQrJ%2Bp%2B5Osd1yhR737Ok7o%2BpTQTh4UQ6bITg%3D%3D',
}#把cookie的内容改为你自己的
url='http://www.oschina.net/action/translate/vote_block'
for r in trange(48700,1,-1):
try:
post(url,headers=httphead,data="id=%s&user=96078" %r,cookies=cookie)
#data内容为"id=段落ID&user=你的用户ID"
sleep(0.1)#如果不加上延时,会因为发包速度过快而无法访问。
except:
print()
print("异常错误~~~")
sleep(0.6)
print()
system("date /t&time /t&echo 完成&pause")
代码改一下变成可以给所有的博客投票,
以下python代码是给所有博文点赞(投票):
"""
2016年5月24日 23:31:59 codegay
进度条库tqdm 的github地址:
https://github.com/noamraph/tqdm
"""
from requests import post
from tqdm import trange
from os import system
from time import sleep
system("title 给所有的博文刷赞~")
system("echo %date%--%time%&echo 积分刷起来~~~")
print()
#tqdm是一个字符界面的进度条库
#安装命令pip install tqdm
httphead={'Accept':'*/*',
'Origin':'http://my.oschina.net',
'X-Requested-With':'XMLHttpRequest',
'User-Agent':'Safari/537.36',
'DNT':'1',
'Referer':'http://my.oschina.net/u/186074/blog/680717',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6',
'Content-Type':'application/x-www-form-urlencoded',
}
cookie={'aliyungf_tc':'AQAAALDYyTFLZwwAcqTY3pZyAZSxJNIk',
'oscid':'nVDZrYAPMi%2FR2DZLfIcwbadLUjBb%2BWuZNxhgCRaV59KRNuCVjUrMHg9OtGoiahQwwRTnT13C%2BF4Vu31QIkTRPvcpcBKVm%2FG%2BQfTw6q3ZCz7zQa7OpgMaD%2BsIy9RU4DtH',
}#把cookie的内容改为你自己的
url='http://my.oschina.net/action/blog/vote'
for r in trange(681017,1,-1):
try:
post(url,headers=httphead,data="id=%s&user=2772660" %r,cookies=cookie)
#data内容为"id=段落ID&user=你的用户ID"
sleep(0.15)
except:
print()
print("异常错误~~~")
sleep(0.6)
print()
system("echo %date%--%time%&&echo 完成&pause")
坑点:
1、如果开着fiddler,运行python程序的时候,会走fiddler的代理,发包速度会大降低,大约是几秒一个包.
2、python单进程发包速度大约是一秒10个左右(没有测试过,估计的),osc会检测访问频率,频率过高会显示一个错误页。所以有必要加sleep限制一下发包的速度。
3、我已经被红薯封号。所以,你们懂的,再慢点。
好像看了一些奇怪的东西