suchen
Heimphp教程PHP源码全自动小说订阅微信推送

全自动小说订阅微信推送

May 25, 2016 pm 05:00 PM
VollautomatischRoman订阅

<?php
header("Content-type: text/html;charset=utf-8");
//set_time_limit(0);

$dbname = SAE_MYSQL_DB;

 $host = SAE_MYSQL_HOST_M;
 $port = SAE_MYSQL_PORT;
 $user = SAE_MYSQL_USER;
 $pwd = SAE_MYSQL_PASS;

$connect = @mysql_connect("{$host}:{$port}",$user,$pwd,true);
if(!$connect) {
 die("Connect Server Failed:". mysql_error());
}

if(!mysql_select_db($dbname,$connect)) {
 die("Select Database Failed:". mysql_error($connect));
}

mysql_query("set names &#39;utf8&#39;");

$rules = array(
&#39;start&#39;=>&#39;http://www.douluodalu.com.cn/jueshitangmen/6860.html&#39;,//开始采集的url
&#39;title&#39;=>&#39;/<h1>(.*?)</h1>/&#39;,//文章title
&#39;time&#39;=>&#39;/发布时间:(.*?) /&#39;,//发布时间
&#39;content&#39;=>&#39;/"></div><p>([sS]*?)<div align=center>/&#39;,//内容
&#39;next&#39;=>&#39;/下一篇: <a href="(.*?)"/&#39;,//下一篇网址
);


//每次排序,取出上一次的最后一篇url
$url = getLatest();

//最后一章的下一篇为空,由此循环
while($url != null && $url !=""){
 $value = get($url);

 $value = _prefilter($value);//去除空白字符,空格,回车
 $context = getContent($value);
$context[&#39;url&#39;] = $url;//当前url,同时还有下一篇的url
 $url = $context[&#39;next&#39;];
var_dump($url);
//防止重复
if(storage($context)){
storageWP($context);
};
}
echo"采集结束";
mysql_close($connect);


function storage($content_array){
global $connect;
$sql ="insert into `articles` (`id`, `title`, `time`, `url`, `content`) values(null,
&#39;{$content_array[&#39;title&#39;]}&#39;,
&#39;{$content_array[&#39;time&#39;]}&#39;,
&#39;{$content_array[&#39;url&#39;]}&#39;,
&#39;{$content_array[&#39;content&#39;]}&#39;);";
$result = mysql_query($sql,$connect);
return $result;
}

function storageWP($content_array){
global $connect;
$result = mysql_query("select max(ID) from wp_posts;",$connect);

$row = mysql_fetch_row($result);
$last_id = $row[0] +1 ;
$sql ="INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES (null,1,&#39;{$content_array[&#39;time&#39;]}&#39;, &#39;{$content_array[&#39;time&#39;]}&#39;, &#39;{$content_array[&#39;content&#39;]}&#39;, &#39;{$content_array[&#39;title&#39;]}&#39;, &#39;&#39;, &#39;publish&#39;, &#39;open&#39;, &#39;open&#39;, &#39;&#39;, &#39;{$content_array[&#39;title&#39;]}&#39;, &#39;&#39;, &#39;&#39;, &#39;{$content_array[&#39;time&#39;]}&#39;, &#39;{$content_array[&#39;time&#39;]}&#39;, &#39;&#39;, 0, &#39;http://iniu.sinaapp.com/?p={$last_id}&#39;, 0, &#39;post&#39;, &#39;&#39;, 0);";

$result = mysql_query($sql,$connect);

$sql ="INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`, `term_order`) VALUES({$last_id}, 1, 0);";

$result = mysql_query($sql,$connect);
return $result;
}

function getContent($value){
global $rules; 
preg_match($rules[&#39;title&#39;],$value, $title);

preg_match($rules[&#39;time&#39;],$value, $time);

preg_match($rules[&#39;next&#39;],$value, $next);

preg_match($rules[&#39;content&#39;],$value, $content);

$context = array(
&#39;title&#39; => addslashes($title[1]),
&#39;time&#39; => $time[1],
&#39;next&#39; => addslashes($next[1]),
&#39;content&#39; => addslashes($content[1])
);
return $context;
}


function getLatest(){
 global $connect;
 global $rules; 
 $sql ="SELECT url FROM `articles` ORDER BY id DESC LIMIT 1";
 $result = mysql_query($sql,$connect);
$row=mysql_fetch_row($result);

if($row){
return $row[0]; 
}else{
return $rules[&#39;start&#39;];
}

}


function get($url){
 $ch = curl_init($url) ;
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ;
 curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ;
 $value = curl_exec($ch) ;
curl_close($ch);
 return $value;
}


function _prefilter($output) {
strip_tags($output);
$output=preg_replace("///[Sftv ]*?;[r|n]/","", $output);
$output=preg_replace("/<!--[sS]*?-->/","", $output);
$output=preg_replace("/>[s]+</","><", $output);
$output=preg_replace("/;[s]+/",";", $output);
$output=preg_replace("/[s]+}/","}", $output);
$output=preg_replace("/}[s]+/","}", $output);
$output=preg_replace("/{[s]+/","{", $output);
$output=preg_replace("/([s]){2,}/","$1", $output);
$output=preg_replace("/[s]+=[s]+/","=", $output);
$output=preg_replace("/<br />/","",$output);
$output=preg_replace("/n/","",$output);
$output=preg_replace("/ /","",$output);
return $output;
}


?>

Stellungnahme
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Beste grafische Einstellungen
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. So reparieren Sie Audio, wenn Sie niemanden hören können
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat -Befehle und wie man sie benutzt
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

MinGW – Minimalistisches GNU für Windows

MinGW – Minimalistisches GNU für Windows

Dieses Projekt wird derzeit auf osdn.net/projects/mingw migriert. Sie können uns dort weiterhin folgen. MinGW: Eine native Windows-Portierung der GNU Compiler Collection (GCC), frei verteilbare Importbibliotheken und Header-Dateien zum Erstellen nativer Windows-Anwendungen, einschließlich Erweiterungen der MSVC-Laufzeit zur Unterstützung der C99-Funktionalität. Die gesamte MinGW-Software kann auf 64-Bit-Windows-Plattformen ausgeführt werden.

EditPlus chinesische Crack-Version

EditPlus chinesische Crack-Version

Geringe Größe, Syntaxhervorhebung, unterstützt keine Code-Eingabeaufforderungsfunktion

SublimeText3 chinesische Version

SublimeText3 chinesische Version

Chinesische Version, sehr einfach zu bedienen

SublimeText3 Linux neue Version

SublimeText3 Linux neue Version

SublimeText3 Linux neueste Version

Senden Sie Studio 13.0.1

Senden Sie Studio 13.0.1

Leistungsstarke integrierte PHP-Entwicklungsumgebung