書籍や記事に関する基本情報を取得するために、WorldCat.orgの検索結果を解析しようとしています。正規表現でウェブサイトを解析できない
典型的な検索結果(と私はテストのために使用しています1)はここで見つけることができます: http://www.worldcat.org/search?q=ti%3Aorganizations&fq=dt%3Abks&qt=advanced&dblist=638
そのページのHTMLはここにある:ここでhttp://pastebin.com/w2U91F1i
は、私は「正規表現です
$data = file_get_contents($url);
preg_match_all('/<div class="oclc_number">(.*?)<\/div>\n.*?<div class="name">\n.*?<a href="(.*?)"><strong>(.*?)<\/strong><\/a>\n.*?\n\n<div class="author">by\s(.*?)<\/div><div class="type">.*?<span class=\'itemType\'>(.*?)<\/span>.*?\n.*?<span class="itemLanguage">(.*?)<\/span>.*?<div class="type">Publication:\s*?(.*?)<\/div>/', $data, $topics, PREG_SET_ORDER);
私はregexrツール(http://gskinner.com/RegExr/)と、この式を使用すると、それだけで正常に動作します(E:各エントリについての基本的な詳細をキャプチャするためにPHPのpreg_match_allを使用してメートルxcept私は\ nの代わりに\ rを使います - 通常は\ rは私のためには機能しません)。しかし、preg_match_allは毎回空の配列を返します。
私が間違っていることについての手掛かりはありますか?
。 –
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – Phil
@Ignacio短いと甘い、それは大好きだが、それほど役に立たない。 – tchaymore