csdn模拟登陆

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan

首先声明本模拟不稳定,有时会出现登陆不进去.
模拟的原理请参考blog.csdn.net/mayongzhan的文章,相关的知识也请参考blog.csdn.net/mayongzhan.
原来是因为csdn的metaweblog不能发布类别,所以采用模拟登陆然后发布.当然也发现了不少csdn秘密,比如隐藏的用于发送垃圾邮件
的field,还有很多csdn只隐藏没删掉的功能.有兴趣大家可以尝试一下,看看是否被封掉.
回归xmlrpc了.这个东西发布出来给大家欣赏一下 by MyZ.

一些其他的hidden fields

发布到网页
&ctl00%24cphContent%24EntryEditor1%24ckbPublished=on

允许在Blog首页显示
&ctl00%24cphContent%24EntryEditor1%24chkIsAggregated=on

将正文内容复制到剪切板(只在IE下有效)
&ctl00%24cphContent%24EntryEditor1%24chkCopytoClipboard=on

显示在我的主页
&ctl00%24cphContent%24EntryEditor1%24chkDisplayHomePage=on

加站外好友邮件AddFriend.aspx

发邮件给站外好友
ctl00$cphContent$EntryEditor1$ckbMailTo
发短消息给站内好友
ctl00$cphContent$EntryEditor1$ckbMessageTo
推荐个编辑
ctl00$cphContent$EntryEditor1$ckbRecommendTo

看到了吧.还有发邮件的功能,就是前一段时间出现的la圾邮件.本身如果是要推广的话...可以试试.

正文.上代码

--------------------------------------------------------------------------------------------

test.php

<?php
/**
 * @name test.php
 * @date Sun Jul 20 12:31:20 CST 2008
 * @copyright 马永占(MyZ)
 * @author 马永占(MyZ)
 * @link http://blog.csdn.net/mayongzhan/
 */

//header("Content-type: text/html;charset=utf-8");
header("Content-type: image/jpeg");
session_start();

$url = &apos;http://hi.csdn.net/IndexLogIn.aspx&apos;;
$url2 = &apos;http://hi.csdn.net/IndexLoginImage.aspx&apos;;

$post = 1;
$returntransfer = 1;
$port = 80;
$header = 0;
$nobody = 0;
$followlocation = 1;

$cookie_jar = tempnam(&apos;./tmp&apos;,&apos;cookie.txt&apos;);
$_SESSION[&apos;cookie_jar&apos;] = $cookie_jar;

$ch = curl_init();
$options = array(CURLOPT_URL => $url,
     CURLOPT_HEADER => $header,
     CURLOPT_NOBODY => $nobody,
     CURLOPT_PORT => $port,
     CURLOPT_RETURNTRANSFER => $returntransfer,
     CURLOPT_FOLLOWLOCATION => $followlocation,
     CURLOPT_COOKIEJAR => $cookie_jar
                 );
curl_setopt_array($ch, $options);
$temp = curl_exec($ch);
curl_close($ch);

//echo $temp;

preg_match_all(&apos;/id=/"__VIEWSTATE/" value=/"(//[0-9a-z]+)" //>/i&apos;,$temp,$tempArr);
preg_match_all(&apos;/id=/"__EVENTVALIDATION/" value=/"(//[0-9a-z+]+)" //>/i&apos;,$temp,$tempArr2);

$_SESSION[&apos;__VIEWSTATE&apos;] = $tempArr[1][0];
$_SESSION[&apos;__EVENTVALIDATION&apos;] = $tempArr2[1][0];

$ch2 = curl_init();
$options2 = array(CURLOPT_URL => $url2,
     CURLOPT_HEADER => $header,
     CURLOPT_NOBODY => $nobody,
     CURLOPT_PORT => $port,
     CURLOPT_RETURNTRANSFER => $returntransfer,
     CURLOPT_FOLLOWLOCATION => $followlocation,
     CURLOPT_COOKIEFILE => $cookie_jar,
     CURLOPT_REFERER => $url
                 );
curl_setopt_array($ch2, $options2);
$temp = curl_exec($ch2);
curl_close($ch2);

echo $temp;

//$tem = file_get_contents($cookie_jar);print_r($tem);

//CURLOPT_URL是要得到内容的地址
//CURLOPT_HEADER是要得到的头 
//CURLOPT_NOBODY是要得到的内容 
//CURLOPT_PORT是端口
//CURLOPT_RETURNTRANSFER是要把输出的内容放到buffer中,可以被echo或者赋予某变量
//CURLOPT_POST是标准的提交
//CURLOPT_POSTFIELDS是提交的内容
//CURLOPT_COOKIEJAR是要保存的cookie
//CURLOPT_COOKIEFILE是从文件读取cookie并提交
//CURLOPT_FOLLOWLOCATION启用时会将服务器服务器返回的“Location:”放在header中递归的返回给服务器
//CURLOPT_MAXREDIRS限定递归返回的数量
//CURLOPT_HTTPHEADER设置一个header中传输内容的数组
//CURLOPT_REFERER设置header中"Referer:"部分的值
//CURLOPT_USERAGENT在HTTP请求中包含一个”user-agent”头的字符串。
//CURLOPT_ENCODING设定header中“Accept-Encoding: ”部分的内容,支持的编码格式为:"identity","deflate","gzip"。如果设置为空字符串,则表示支持所有的编码格式
//CURLOPT_COOKIE设定HTTP请求中Set-Cookie:部分的内容
?>

--------------------------------------------------------------------------------------------

test2.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="author" content="马永占(MyZ)" />
<meta name="Copyright" content="马永占(MyZ)" />
<meta http-equiv="Content-Language" content="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<iframe src="test.php" scrolling="No" frameborder="0" width="400px" height="100px"></iframe>
<form action="test3.php" method="POST">
VerifyCode:<input type="text" name="VerifyCode" /><br />
<input type="submit" value="登陆" />
</body>
</html>

--------------------------------------------------------------------------------------------

test3.php

<?php
/**
 * @name test3.php
 * @date Sun Jul 20 12:31:30 CST 2008
 * @copyright 马永占(MyZ)
 * @author 马永占(MyZ)
 * @link http://blog.csdn.net/mayongzhan/
 */

header("Content-type: text/html;charset=utf-8");
session_start();

$url = &apos;http://hi.csdn.net/IndexLogIn.aspx&apos;;

$post = 1;
$returntransfer = 1;
$port = 80;
$header = 0;
$nobody = 0;
$followlocation = 1;

$request = &apos;__VIEWSTATE=&apos;.urlencode($_SESSION[&apos;__VIEWSTATE&apos;]).&apos;&__EVENTVALIDATION=&apos;.urlencode($_SESSION[&apos;__EVENTVALIDATION&apos;]).&apos;&UserName=testman110&UserPwd=testman111111&VerifyCode=&apos;.$_POST[&apos;VerifyCode&apos;].&apos;&buttonLogin=&apos;.urlencode(&apos; 登 录 &apos;);

$cookie_jar = $_SESSION[&apos;cookie_jar&apos;];

$ch = curl_init();

$options = array(CURLOPT_URL => $url,
     CURLOPT_HEADER => $header,
     CURLOPT_NOBODY => $nobody,
     CURLOPT_PORT => $port,
     CURLOPT_POST => $post,
     CURLOPT_POSTFIELDS => $request,
     CURLOPT_RETURNTRANSFER => $returntransfer,
     CURLOPT_FOLLOWLOCATION => $followlocation,
     CURLOPT_COOKIEJAR => $cookie_jar,
     CURLOPT_COOKIEFILE => $cookie_jar,
     CURLOPT_REFERER => $url
                 );
curl_setopt_array($ch, $options);
$temp = curl_exec($ch);
curl_close($ch);

echo $temp;
?>

--------------------------------------------------------------------------------------------

the end

php不比任何的东西差.包括已经写出来csdn登陆的python c#.

转载于:https://www.cnblogs.com/xingyong/archive/2011/07/17/2108626.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值