php採集遠端文章簡單類

2022-08-28 17:39:08 字數 1403 閱讀 4851

public $pagestring = '';

private $db;

function __construct()

function geturlfile($url) else

return trim($content);

}function get_all_url($code)

function get_sub_content($str, $start, $end)

$str = explode($start, $str);

$str = explode($end, $str[1]);

return $str[0];

}function vd($var)

<?php

define('root_path', str_replace('\\\\', '/', dirname(__file__)));

include root_path."/gather.class.php";

set_time_limit(0);

header("content-type: text/html; charset=gb2312");

//目標**

$url = '';

//例項化採集機器

$gather = new gather();

//獲取目標**html

$html = $gather->geturlfile($url);

//定義採集列表區間

$start = '';

$end = '';

//獲取區間內的文章url和title

$code = $gather->get_sub_content($html, $start, $end);

$newsary = $gather->get_all_url($code);

//列印出結果

//$gather->vd($newsary);

$targeturl = $newsary['url'][0];

//獲取目標**html

$html = $gather->geturlfile($targeturl);

//定義採集列表區間

$start = '';

$end = '';

//獲取區間內的文章url和title

$code = $gather->get_sub_content($html, $start, $end);

$killhtml = '';

$killhtml2 = '

';$code = str_replace($killhtml, "", $code);

$code = str_replace($killhtml2, "", $code);

$gather->vd($code);

?>

PHP推薦簡單採集微博文章資訊自用

weibo spider 微博爬蟲php指令碼 weibo spider是微博專案爬蟲指令碼的整理,以php語言開發,mysql作為儲存資料庫。快速上手 php weibo.php 2018 09 14 15 46 20 id.1 1 0 羅永浩 is ad 2018 09 14 15 46 20 ...

PHP例項 CURL實現簡單採集

在php中我們可以通過編寫curl來實現採集的功能,先分析需要採集的資料的 的特點,加入到我們的curl的屬性中來,實現我們定製採集的功能,最終得到我們需要的結果。curl的使用 preg match all array filter explode php中建立curl請求的基本步驟 1 建立乙個...

用php寫的簡單採集器

通常我們所說的採集器又叫做小偷程式,主要是用來抓取別人網頁內容的。關於採集器的製作,其實並不難,就是遠端開啟要採集的網頁,然後用正規表示式將需要的內容匹配出來,只要稍微有點正規表示式的基礎,都能做出自己的採集器來的。前幾天做了個 的程式,因為怕更新麻煩,順帶就寫了個採集器,採集八路中文網的,功能比較...