分享一个 CSDN 自动评论角本
先修改帐户名和密码
import requests
from BeautifulSoup import BeautifulSoup
import time
def commitfunc(source_id, refer):
print source_id, refer
commiturl='http://download.csdn.net/index.php/comment/post_comment?jsonpcallback=jsonp1419934439524&sourceid='+source_id+'&content=%E6%88%90%E5%8A%9F%E9%85%8D%E5%AF%B9%EF%BC%8C%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E3%80%82&rating=5&t=1419935091974'
commitdata = {
"Accept" : "text/javascript, application/javascript, */*",
"Accept-Encoding" : "gzip, deflate, sdch",
"Accept-Language" : "zh-CN,zh;q=0.8",
"Connection" : "keep-alive",
"Content-Type" :"application/x-www-form-urlencoded",
"cookie" : "",
"Host" : "download.csdn.net",
"Refer" : refer,
"User-Agent" : "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36",
"X-Requested-With" : "XMLHttpRequest",
"jsonpcallback" : "jsonp1419934439524",
"sourceid" : source_id,
"content" : "a good resource, it's worth to download it",
"rating" : "5",
"t" : "1419935091974",
}
resp = sess_source.post(commiturl, commitdata)
print resp.text
def GetPageCount():
url_source_page = url_source + "1"
html_source = sess_source.get(url_source_page).text
soup_source = BeautifulSoup(html_source)
#resource_once = soup_source.findAll('h3')
page_count = soup_source.find('div', attrs={'class': "page_nav"}).text
page_list = page_count.split()
page_ac = page_list[2].split('&')
return page_ac[0][1:len(page_ac[0])-1]
def CommitWholePage(page_nu):
url_source_page = url_source + page_nu
html_source = sess_source.get(url_source_page).text
soup_source = BeautifulSoup(html_source)
resource_once = soup_source.findAll('h3')
for element in resource_once:
if(len(element) > 1):
try:
#print type(element.contents[0].attrs[0][1])
#print element.contents[0].attrs[0][1]
attr = element.contents[0].attrs[0][1].split('/')
reftext = '/detail/' + attr[2] + '/' + attr[3] + '#comment'
result = soup_source.findAll('a', attrs={'href' : reftext, 'class' : 'btn-comment'})
if len(result) != 0:
#sess_source.get(url_source_page)
commitfunc(attr[3], attr[2])
print attr[2]
print attr[3]
print "sleep"
time.sleep(70)
except Exception, e:
s = traceback.format_exc()
print s
def logincsdn():
html_login = sess_source.get(url_login).text
soup_login = BeautifulSoup(html_login)
lt_value = soup_login.findAll('input', attrs={'name': "lt"})[0]['value']
execution_value = soup_login.findAll('input', attrs={'name': "execution"})[0]['value']
data_login = {
"lt" : lt_value,
"execution" : execution_value,
"_eventId" : "submit",
"username" : "用户名",
"password" : "密码"
}
sess_source.post(url_login, data_login)
print "start auto comment"
#main begin
url_login = "http://passport.csdn.net/account/login"
url_source = "http://download.csdn.net/my/downloads/"
sess_source = requests.session()
logincsdn()
total_page = GetPageCount()
print "total page",total_page
for num in range(1,int(total_page)+1):
print "current page", num
CommitWholePage(str(num))
print "app stop "
分享一个 CSDN 自动评论角本的更多相关文章
- CSDN 自动评论
转载说明 本篇文章可能已经更新,最新文章请转:http://www.sollyu.com/csdn-auto-reviews/ 说明 当打开http://download.csdn.net/my/do ...
- 分享一个微信自动跳转外部浏览器下载app的api接口!
现在微信渠道可以说是拉新最快的渠道,因为微信具备强裂变性.但是目前微信对第三方下载链接的拦截是越来越严格了,那么想要在微信内肆无忌惮地推广链接就需要用到微信跳转浏览器的接口,那如何获取该接口呢? ...
- python登录csdn并自动评论下载资源脚本
功能 1.自动登录csdn 2.查找未评论的资源并自动评论 用到的库 1.python自带的requests,获取以及发送网页数据 2.python自带的time,用作休眠,csdn资源一段时间内只允 ...
- 分享一个快速设置背景的js 自动获取背景图的长宽
我来分享一个快速设置背景的js (需要jq支持!) 快速切图铺页面用---就是不需要手动输入背景图的长宽 自动获取背景图的长宽 : <div class="wrap"> ...
- 【微信支付】分享一个失败的案例 跨域405(Method Not Allowed)问题 关于IM的一些思考与实践 基于WebSocketSharp 的IM 简单实现 【css3】旋转倒计时 【Html5】-- 塔台管制 H5情景意识 --飞机 谈谈转行
[微信支付]分享一个失败的案例 2018-06-04 08:24 by stoneniqiu, 2744 阅读, 29 评论, 收藏, 编辑 这个项目是去年做的,开始客户还在推广,几个月后发现服务器已 ...
- 分享一个常用Adb命令
分享一个常用Adb命令 首先 首先感谢@xuxu的常用adb命令,收益良多,但是已经不能满足于我,所以补充了下. 再者 好久没发帖了,最近论坛老司机们都在讨论/总结,我就用这个干货回报吧. 最后 基于 ...
- 作业二:个人编程项目——编写一个能自动生成小学四则运算题目的程序
1. 编写一个能自动生成小学四则运算题目的程序.(10分) 基本要求: 除了整数以外,还能支持真分数的四则运算. 对实现的功能进行描述,并且对实现结果要求截图. 本题发一篇随笔,内容包括: 题 ...
- 分享一个Mongodb PHP封装类
<?php /** * Mongodb 基本操作API,支持基本类似关系统型数据库的操作接口 * * @version 1.0 * [说明] * * 1:该版本API实现了 Mongodb 中最 ...
- 分享一个强大的采集类,还可以模拟php多进程
做采集的时候,可以使用file_get_contents()去获取网页源代码,但是使用file_get_contents采集,速度慢,而且超时时间,不好控制.如果采集的页面不存在,需要等待的时间很长. ...
随机推荐
- poj 2503 Babelfish(Map、Hash、字典树)
题目链接:http://poj.org/bbs?problem_id=2503 思路分析: 题目数据数据量为10^5, 为查找问题,使用Hash或Map等查找树可以解决,也可以使用字典树查找. 代码( ...
- Qt控制台和带窗口的区别_mickelfeng_新浪博客
Qt控制台和带窗口的区别_mickelfeng_新浪博客 t控制台和带窗口的区别 (2012-04-30 10:50:53) 标签: 杂谈 分类: C/C ...
- 【网络协议】TCP中的四大定时器
前言 对于每个TCP连接,TCP一般要管理4个不同的定时器:重传定时器.坚持定时器.保活定时器.2MSL定时器. 重传定时器 非常明显重传定时器是用来计算TCP报文段的超时重传时间的(至于超时重传时间 ...
- [LeetCode] Longest Substring Without Repeating Characters (LinkedHashSet的妙用)
Given a string, find the length of the longest substring without repeating characters. For example, ...
- C - N皇后问题(搜索)
Description 在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上. 你的任务是,对于给定的N,求出有多少种合 ...
- win7安装 Apache2.2 PHP5.3 MySQL5.6
. APACHE2.2 经典参考资料 http://blog.csdn.net/yousuosi/article/details/9859507 官方下载地址 http://mirror.bi ...
- Linux下Tomcat catalina.out自动归档,以及logrotate 配置详解
Linux下Tomcat catalina.out自动归档 如果 catalina.out 日志达到 2GB 大小的时候,Tomcat 因为缓存问题,便没有办法继续输出日志了. 为了避免这种情况,你 ...
- python学习之lambda匿名函数
1 Python支持运行时使用“lambda”建立匿名函数(anonymous functions that are not bound to a name). python "lambda ...
- Arcengine 开发,FeatureClass新增feature时“The Geometry has no z-value”或"The Geometry has null z-value"的解决方案
Arcengine 开发,当图层含有Z值时,新增的feature没有Z值就会 出现“The Geometry has no z-value”的错误.意思很明显,新增的geometry没有Z值. 此时按 ...
- poj 2094 多项式求和。
/** 给出多项式 p(x) = an*x^n + an-1*x^(n-1)..... + a1*x + a0; 给定n,l,k,m 计算 x 从 l到 l+k-1 的p(x)的后m 位的平方的和 用 ...