Here’s the basic principal behind spiders.
$html = file_get_contents('http://www.example.com');
$dom = new DOMDocument();
@$dom->loadHTML($html);
// grab all the on the page
$xpath = new DOMXPath($dom);
$hrefs = $xpath->evaluate("/html/body//a");
for ($i = 0; $i < $hrefs->length; $i++) {
$href = $hrefs->item($i);
$url = $href->getAttribute('href');
echo $url.'<br />';
}
Exactly what I needed. Thanks.
Perfect for affiliate sites!
WAAAAO ITS GREAT….I WAS SEARCHING FOR THIS ONLY
I didnt understand quite how to use this? where to I type that? I’m kinda confused.. I need more explanation
Thanks
EXACTLY, how to use all these php snippet
see, my method is more clear (hope that they teach us HOW)
try a fews of these already, I don’t know how to implement these php snippets
This post is just too good. thumbs up!!
keep up the good work ;)
Muchas gracias por la ayuda!
Works perfect! thx!
Can someone please show me step by step in how to use this. Thank you in advance
perfect.Was using php simple DOM but not good enough like this.!
The unique power of PHP and DOM unleashed. cURL and REGEX based techinques can never match this. Though they have their own uses, ofcourse. Many thanx.
how to follow all other children pages ?
Thanks.
Whats about performance on xPath?
This is amazing. Thank you so much.
Thanks, very simple. Great!
Hi, tnx it’s very helpful yet I have a question,
what if I have to get a link with a specific class
wil this do it? : (html/body//a.class)
Hi
Is there a curl version of this?
I’ll be appreciate that if anyone write it with curl.
tnx
Thanks Man. This is exactly what I need.
This code is for only one link, I need any link… like http://www.abc.com … or … http://www.xyz.com etc