Skip to content

Instantly share code, notes, and snippets.

@FGFW
Created May 9, 2016 19:55
Show Gist options
  • Save FGFW/face8d8903dc6744bd9f7427809987ae to your computer and use it in GitHub Desktop.
Save FGFW/face8d8903dc6744bd9f7427809987ae to your computer and use it in GitHub Desktop.
python3使用requests删除闪存.py
"""
python3使用requests删除闪存.py
2016年5月9日 22:27:30 codegay
闪存ing.cnblogs.com是一个类似饭否的功能
本程序功能是删除非幸运闪的闪存
参考资料requests文档:
http://cn.python-requests.org/zh_CN/latest/
"""
import requests
import re
from time import sleep
def timeit(fn):
import time
def v():
start=time.clock()
fn()
end=time.clock()-start
print(fn.__name__,"运行耗时:",end)
return v
url='http://ing.cnblogs.com/ajax/ing/GetIngList?IngListType=my&PageIndex=1&PageSize=30'
head={'Accept':'application/json, text/javascript, */*; q=0.01',
'Origin':'http://ing.cnblogs.com',
'X-Requested-With':'XMLHttpRequest',
'Content-Type':'application/json; charset=UTF-8',
'DNT':1,
'Referer':'http://ing.cnblogs.com/mobile/',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6',
}
cookies={'.CNBlogsCookie':'678x34BD16E61A87726AF2203F849339'}
s=requests.Session()
@timeit
def geting():
data={'ingId':'878581'}
r=s.get(url,cookies=cookies)
text=r.text
ingid=re.findall('''feed_content_(\d+)(.+?天上的星星不说话.+?DelIng)''',text,re.DOTALL)
#ingid=re.findall('''feed_content_(\d+)''',text)
#print(ingid)
notlucky=[a for a,b in ingid if 'ing_icon_lucky' not in b]
for x in notlucky:
data['ingId']=x
try:
sdel=s.post("http://ing.cnblogs.com/ajax/ing/del",cookies=cookies,data=data)
print("ID:",x,sdel.text)
except:
pass
while True:
geting()
sleep(60*10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment