如何parse
到HTML data
一个PHP array PHP
HTML 数据
<div class="test">
<strong>ID</strong>
<a href="a.html" title="a html">123456</a><br>
<label class='label'>Occupation </label>
House wife <br>
<label>Language?</label>
English <br>
<label style="width:50%">Basic Language Knowledge of?</label>
Hindi <br>
<label>Start date</label>
Nov 2013 <br>
<label>Other Info</label>
yes <br>
<label>age</label>
19 <br>
<label>Gender</label>
Female <br>
<strong>Address</strong>
India <br><br>
<p>Hi, <br>
Lorem ipsum doner inut</p>
</div>
我试过这个,
<?php
$html='Let above html to parse';
preg_match_all('/<label\s(.*)>(.*)<\/label>/U',$html,$m);
print_r($m);
// gives all label contents only but I need pair of label text
// and value showing after it
?>
输出如,
Array('ID'=>123456,'link'=>'a.html','职业'=>'房主','语言?'=>'英语','基本语言知识?'=>'印地语','开始日期'=>'Nov 2013','Other Info'=>'yes','age'=>'19','Gender'=>'Female','Address'=>'India' ,'description'=>'嗨,Lorem ipsum doner inut');
是的,forgot to mention
我正在使用ganonscraping