■ 1. まず php-xml のインストール yum install php-xml ■ 2. 実際のサイトからスクレイピングを行って Xpath で要素を取得のPHPコード test.server.com から WEBページを取得してきて<div id="myid">の要素を取得します。 $url='http://test.server.com'; // file_get_contents を使うより高速、ただしメモリは食う require_once 'HTTP/Client.php'; $client =& new HTTP_Client(); $client->get($url); $response = $client->currentResponse(); $dom = @DOMDocument::loadHTML( $response['body']); $xml = sim
Getting Started Introduction A simple tutorial Language Reference Basic syntax Types Variables Constants Expressions Operators Control Structures Functions Classes and Objects Namespaces Enumerations Errors Exceptions Fibers Generators Attributes References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Predefined Attributes Context options and parameters Su
PHP5でのスクレイピングについて調査してみた。 正規表現でやってもいいのだけど。 PHP5でやるのだからSimpleXMLでやってみたい。 となると、いかに未整形HTMLを整形済にしてSimpleXMLとするかが 課題となる。これについて調べてみた。 ↓これが答え。なるものを見つけました。 HTMLParser(PEARのXML_HTMLSax3使用)orTidyで整形してるそうです。 HTMLをXML化してDOMやXPathで操作するWebスクレイピング用PHPクラス : Under Construction, Baby: # SimpleXML+HTMLParser or Tidy+HTTP_Request+Cache_Lite http://www.rcdtokyo.com/ucb/contents/i000851.php これで調査終了。というのも寂しいので。 もう少しお手軽にで
Don't let me cry(右手を回して拳のつきあげ) Don't let me sigh( 左手を回して拳のつきあげ)呪文のように唱えて(両手を頭の上でクラップジャンプ) SimpleXMLの使い方メモ。 CDATAなんてのはパースできないので諦める。 対象、自分のはてぶ <?php $xml = @simplexml_load_file('http://b.hatena.ne.jp/cockok/atomfeed'); すべてのタイトルを表示する foreach ($xml->entry as $entry) { var_dump($entry->title); } すべてのタイトルを表示する(XPath) $xml->registerXPathNamespace('atom', 'http://purl.org/atom/ns#'); foreach($xml->
I’ve recently switched my blog from b2evolution back to WordPress. The good news is both “no more spam :)” and “the admin panel works in Safari”, but on the downside I missed the multiblog feature that attracted me to b2evolution in the first place. There is WordPress MU, I suppose, but after coming across a few plugins that warned they didn’t work with WordPress MU, that option didn’t look very a
Yahooの日本語形態素解析Webサービスを使ってみる Yahooが日本語形態素解析Webサービス・WebMAを公開しました。 ここでは、このWebサービスとともに、日本語形態素解析の説明をしてみます 形態素解析 - Wikipedia -に、詳細説明があります。 簡単に言うと、日本語の構文を分析して、各パーツの品詞(名詞、動詞、形容詞、助詞など)に分け、例えば、名詞の使われている順にページ内でどんな言葉が一番使われているのかを決定し、それにあわせた広告を表示したり(コンテンツマッチ型の広告)することができるわけです。 一番有名なサービスが、googleのadsense。 日本語形態素解析というのは、古くからあるサービスで、 比較的メジャーなのを挙げてみると、 MeCab、ChaSen、JUMAN、KAKASI なんてのがあります。 どれも、UNIX(LINUX)にインストー
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く