PHP Screen-scraping methods
I have a site http://www.coldwellbankerpbr.com/listings.aspx that I am trying to grab the listings from, now I need the address and bedroom details, etc however there is no unique identifier besides the text Address (which is repeated several times on t开发者_开发百科he page) I was looking at PHP DOM however that seems to be more of a looking for unique tags (div id's, etc).
Is there any more method I should be looking at for this more text based Address ****** search? The table is something like:
<td width="55">Address</td><td>ADDRESS HERE</td>
Thanks!
I would try XPath if i were you. for example with SimpleXml
$path = "/html/body/form[@id='main']/table/tbody/tr[4]/td/table/tbody/tr/td[1]/table/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr[2]/td[2]"
$xml = new SimpleXmlElement('http://www.coldwellbankerpbr.com/listings.aspx', null, true);
$addresses = $xml->xpath($path);
foreach($addresses as $address) {
echo $address;
}
That XPath should get you the actual text of the addresses for the listings. But you can play with it and read up on XPath to get just about anything you want. In fact you can probably simplify that path a bit.. i just generated in the XPather extension in Firefox to save myself some hassle :-) You can also use XPath with DOMDocument but its a little more complicated to use.
精彩评论