[Asm] 纯文本查看 复制代码
<?php
//发送的内容字段
/**
$title='title5';
$body='body6';
$typeid='1';
$pubdate='pubdate';
$shorttitle='shorttitle';
$tags='tags';
$source='source';
$writer='writer';
$flags='c';
**/
//获取内容
$weburl='http://www.gsdata.cn';
//获取公众号地址
$gs_url='http://www.gsdata.cn/rank/toparc?wxname=ZQHBhDpSYJWq5innNgQ5O0O0O2O0O0O1&wx=dxiang5&sort=-1';//可以在搜搜到的页面获取微信名和地址wxname=xxx和wx=xxxx
$gs_data=postdata($gs_url);
$gs_data=json_decode($gs_data,true);
$gs_count=count($gs_data['data']);
for($i=0;$i<$gs_count;$i++){
$title=$gs_data['data'][$i]['title'];
$pubdate=$gs_data['data'][$i]['posttime'];
$tags=$gs_data['data'][$i]['content'];
$source='网络';
$writer=$gs_data['data'][$i]['name'];
$rand=rand(1,200);//随机数!推荐使用
$flags='';
if($rand > 100){
$flags='c';
}
$shorttitle=$gs_data['data'][$i]['title'];
$typeid='1';//要发布到后台的栏目id
$counts=file_get_contents($gs_data['data'][$i]['url']);
$_cmatch='/<div class="rich_media_content.*?>[\s]+?(.*?)[\s]+?<\/div>/i';
preg_match($_cmatch,$counts,$g_body);
$body=trim($g_body[1]);
$body=preg_replace('/(\s+style=.*?;")/','',$body);
$body=preg_replace('/(\s+class="")/','',$body);
$body=preg_replace('/(<div\s+.*?>)/','',$body);
$body=preg_replace('/(<\/div>)"/','',$body);
$body=preg_replace('/\s+data-ratio="(.*?)"/','',$body);
$body=preg_replace('/(<qqmusic.*?)>(<\/qqmusic>)/','',$body);
$body=preg_replace('/(<mpvoice.*?)>(<\/mpvoice>)/','',$body);
$body=preg_replace('/(<p><span><\/span><\/p><p><\/p>)/','',$body);
$body=preg_replace('/(<p><span><\/span><br \/><\/p>)/','',$body);
$body=preg_replace('/(<p><\/p><p><\/p>)/','',$body);
$body=preg_replace('/(<p><span><br \/><\/span><\/p>)/','',$body);
$body=preg_replace('/(<p><\/p>)"/','',$body);
$body=preg_replace('/(<p><br \/><\/p>)/','',$body);
$body=preg_replace('/(label=".*?")/','',$body);
$body=preg_replace('/(<section class="xmteditor".*?)(<\/section>)/','',$body);
$body=preg_replace('/(<p><span><strong><br \/><\/strong><\/span><\/p>)/','',$body);
if(preg_match("/红包|送送/",$title)){
echo "have AD pass ";
continue;
}
if(empty($body)){
echo "内容不能为空";
continue;
}
$data='title='.$title.'&body='.$body.'&typeid='.$typeid.'&dopost=save&pubdate='.$pubdate.'&shorttitle='.$shorttitle.'&redirecturl=&tags='.$tags.'&source='.$source.'&writer='.$writer.'&typeid2=&keywords='.$tags.'&description=&needwatermark=0¬post=1&channelid=1&remote=0&dellink=1&autolitpic=0&autokey=1&sptype=auto&spsize=3&money=0&ishtml=1&sortup=0&arcrank=0&templet=&username=admin&flags[]='.$flags.'';
$url='http://127.0.0.1/dede/jiekou.php?pw=密码';//织梦后台接口后台地址
postdata($url,$data);
echo $title.'OK ';
//echo $body;
sleep(2);
}
function postdata($url,$data=''){
$header = array (
0 => 'Accept: */*',
1 => 'Accept-Encoding: gzip, deflate',
2 => 'Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
3 => 'Connection: keep-alive',
4 => 'DNT: 1',
5 => 'Host: www.gsdata.cn',
6 => 'Referer: http://www.gsdata.cn/rank/wxrank',
7 => 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0 FirePHP/0.7.4',
8 => 'X-Requested-With: XMLHttpRequest',
9 => 'x-insight: activate',
);
$timeout=20;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //返回数据不直接输出
curl_setopt($ch, CURLOPT_ENCODING, "gzip"); //指定gzip压缩
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //302/301
if(substr($url, 0, 8) === 'https://') {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
}
if(!empty($data)) {
curl_setopt($ch, CURLOPT_POST, 1); //发送POST类型数据
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
if(!empty($cookie)) {
$header[] = $cookie;
}
if(!empty($header)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //使用header头信息
}
curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
$content = curl_exec($ch);
if($error = curl_error($ch)) {
//log error
error_log($error);
}
curl_close($ch);
return $content;
}
?>