今天來做乙個php
電影小爬蟲。
我們來利用******_html_dom的採集資料例項,這是乙個php的庫,上手很容易。
******_html_dom 可以很好的幫助我們利用php解析html文件。通過這個php封裝類可以很方便的解析html文件,對其中的html元素進行操作 (php5+以上版本)
下面我們以 上的列表頁 字母模式展現的列表為例,抓取頁面上的列表資料,以及內容裡面資訊
1<?php
2 include_once '
******_html_dom.php';
3//獲取html資料轉化為物件
4 $html = file_get_html('
');5//
a-z的字母列表每條資料是在id=letter-focus 的div內class= letter-focus-item的dl標籤內,用find方法查詢即為
6 $listdata=$html->find("
#letter-focus .letter-focus-item
");//
$listdata為陣列物件
7foreach($listdata as$key=>$eachrowdata)
19 $cate[$key]=join("
,",$row);//
將影視的資訊存放到陣列中20}
21 }
1 $html = file_get_html('');2 $e = $html->find("
div", 0);3
//標籤
4 $e->tag;5//
外文本6 $e->outertext;7//
內文字8 $e->innertext;9//
純文字10 $e->plaintext;
11//
子元素12 $e->children ( [int
$index] );
13//
父元素14 $e->parent ();
15//
第乙個子元素
16 $e->first_child ();
17//
最後乙個子元素
18 $e->last_child ();
19//
後乙個兄弟元素
20 $e->next_sibling ();
21//
前乙個兄弟元素
22 $e->prev_sibling ();
23//
標籤陣列
24 $ret = $html->find('a'
);25
//第乙個a標籤
26 $ret = $html->find('
a', 0);
原文:
快速開發乙個PHP電影爬蟲
include once html dom.php 獲取html資料轉化為物件 html file get html a z的字母列表每條資料是在id letter focus 的div內class letter focus item的dl標籤內,用find方法查詢即為 listdata html ...
初探python之做乙個簡單小爬蟲
初探python,這個文章屬於自己的乙個總結。所以教程面向新手,無技術含量。python環境linux基本都有,windows下官網也提供了便利的安裝包,怎麼安裝配置網上有很多教程在此就不一一說明。我使用的python版本為python 3.6.4,後面的 也是基於python3的。做乙個小爬蟲離不...
乙個小爬蟲
usr bin env python coding utf 8 sina小爬蟲 site http 不能少哦 reptile sina reptitle site print getting the urls.n reptile sina.get urls site reptile sina.sto...