Forum Moderators: coopster
Here is one ...
[webmasterworld.com...]
With php5 and DOM there is a much cleaner way of doing it. And no regex required ;-)
Here goes -
<?php
$dom->loadHTMLFile('http://www.webmasterworld.com/');
$anchor = $dom->getElementsByTagName('a'); foreach ($anchor as $node) {
$anchor_href=$node->getAttribute('href');
$anchor_text=$node->textContent;
}
?>
Use the STRING functions to compare $anchor_href and $anchor_text.
That's it. Hope it helped,
Saurabh.
Completely Overhauled XML support (Rob, Sterling, Chregu, Marcus)
Still, amazing find!
The user-agent can be set in php.ini. Look under the section "Fopen wrappers".
For more control over referer and other variables, I suggest you use DOM in combo with Curl.
Retrive the HTML file with Curl and then use -
$dom->loadHTML($html_string) instead of
$dom->loadHTMLFile('http://www.webmasterworld.com/');
coopster: AFAIK PHP5 is not recommended on production systems.
Saurabh.