I am writing a script that needs to pick out certain URLS on a page; these URLS, for example, can be http://fiel.com/989898/etc.html
followed b开发者_StackOverflow中文版y ">load</a>
How could I extract these using a regex ?
In javascript:
var links = document.links;
for (var i=0; i<links.length; i++) {
if(links[i].match(/http\:\/\/fiel\.com/i))
{
}
}
in php
$html = '<html><body>....</body></html>';
$doc = new DOMDocument();
@$doc->loadHTML($html);
$links = $doc->getElementsByTagName('a');
foreach ($links as $link) {
if ($link->nodeValue == 'load') {
$data = $link->getAttribute('href');
//do whatever with href
}
}
精彩评论