Code:
|<a\s[^>]*href\s*=\s*(\"??)'.$pData['profile_url'].'\\1[^>]*>'.$aData['link_backlink'].'<\/a>
|<a\s[^>]*href\s*=\s*(\"??)'.$pData['profile_url'].'\\1[^>]*>'.$aData['link_backlink'].'<\/a>
<?php
eregi('href="([^"]+)"[^>]*>([^<]+)', $page->source, $page->links);
print_r($page->links);
?>
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$baseNodes = $xpath->evaluate("//base/@href");
if ($baseNodes->length == 1) {
$baseUrl = rtrim($baseNodes->item(0)->nodeValue, '/');
}
$hrefs = $xpath->evaluate("//a");
$link = '<a href="http://www.google.com">google</a>';
preg_match('/a href="([^"]*?)">([^"]*?)<\/a>/', $link, $matches);
print_r($matches);
should print
Array
(
[0] => a href="http://www.google.com">google</a>
[1] => http://www.google.com
[2] => google
)
$link = '<a href="http://www.google.com">google</a>';
preg_match('/a href="([^"]*?)">([^"]*?)<\/a>/', $link, $matches);
print_r($matches);
should print
Array
(
[0] => a href="http://www.google.com">google</a>
[1] => http://www.google.com
[2] => google
)
$links = '<a rel="nofollow" href="http://www.google.com/" id="extra">google</a>\r\n';
$links .= '<a rel="nofollow" href="http://www.yahoo.com/" id="extra">yahoo</a>\r\n';
$links .= '<a rel="nofollow" href=\'http://www.msn.com/\' id="extra">msn</a>\r\n';
$links .= '<a href="http://www.bing.com/" id="extra">bing</a>\r\n';
$links .= '<a href="http://www.ask.com/" id="extra">ask</a>\r\n';
$uri = 'www.bing.com';
$back = 'bing';
preg_match_all("/<a\s[^>]*href=([\"\']??)(http:\/\/{$uri}*?)([\"\']??)[^>]*>({$back})<\/a>/siU", $links, $matches);
print_r( $matches );
$links = '<a rel="nofollow" href="http://www.google.com/" id="extra">google</a>\r\n';
$links .= '<a rel="nofollow" href="http://www.yahoo.com/" id="extra">yahoo</a>\r\n';
$links .= '<a rel="nofollow" href=\'http://www.msn.com/\' id="extra">msn</a>\r\n';
$links .= '<a href="http://www.bing.com/" id="extra">bing</a>\r\n';
$links .= '<a href="http://www.ask.com/" id="extra">ask</a>\r\n';
$uri = 'www.bing.com';
$back = 'bing';
preg_match_all("/<a\s[^>]*href=([\"\']??)(http:\/\/{$uri}*?)([\"\']??)[^>]*>({$back})<\/a>/siU", $links, $matches);
print_r( $matches );
<?php
$url = 'http://www.crazyfilth.com';
$anchor_text = 'Crazy Porn';
$html = file_get_contents('http://www.filthdump.com');
echo checkUrl($url, $anchor_text, $html);
function checkUrl($url, $anchor_text, $html) {
$found = false;
$dom = new domDocument();
@$dom->loadHTML($html);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $anchor) {
$found_url = $anchor->getAttribute('href');
$urltext = trim($anchor->nodeValue);
if (($found_url == $url) && ($anchor_text == $urltext)) {
return true;
}
}
return false;
}
?>
$links = '<a rel="nofollow" href="http://www.google.com/" id="extra">google</a>\r\n';
$links .= '<a rel="nofollow" href="http://www.yahoo.com/" id="extra">yahoo</a>\r\n';
$links .= '<a rel="nofollow" href=\'http://www.msn.com/\' id="extra">msn</a>\r\n';
$links .= '<a href="http://www.bing.com/" id="extra">bing</a>\r\n';
$links .= '<a href="http://www.ask.com/" id="extra">ask</a>\r\n';
$uri = 'www.bing.com';
$back = 'bing';
preg_match_all("/<a\s[^>]*href=([\"\']??)(http:\/\/{$uri}*?)([\"\']??)[^>]*>({$back})<\/a>/siU", $links, $matches);
print_r( $matches );
$uri = 'http://www.bing.com/';
$uri = str_replace( '/', '\\/', $uri );
$back = 'bing';
preg_match_all("/<a\s[^>]*href=([\"\']??)({$uri}*?)([\"\']??)[^>]*>({$back})<\/a>/siU", $links, $matches);
print_r( $matches );
<?php
$url = 'http://www.crazyfilth.com';
$anchor_text = 'Porn Videos';
$html = file_get_contents('http://aisle69.com/');
echo checkUrl($url, $anchor_text, $html);
function checkUrl($url, $anchor_text, $html) {
$found = false;
$dom = new domDocument();
@$dom->loadHTML($html);
$anchors = $dom->getElementsByTagName('a');
foreach ($anchors as $anchor) {
$found_url = preg_replace('{/$}', '', $anchor->getAttribute('href'));
$urltext = trim($anchor->nodeValue);
if (($found_url == $url) && ($anchor_text == $urltext)) {
return true;
}
}
return false;
}
?>
$url = 'http://www.crazyfilth.com/'; $anchor_text = 'Porn Videos'; $html = '<a href="http://www.crazyfilth.com/?PHPSESSID=777" id="extra">Porn Videos</a>';
<?php
$content = file_get_contents('test.html');
$regex = "/<a.*? href=(\"|')(.*?)(\"|').*?>(.*?)<\/a>/i";
if (preg_match_all($regex,$content,$matches,PREG_SET_ORDER)) {
foreach ($matches as $match) {
// echo $match[0]; // full link including href
// echo $match[1]; // type of opening quote
// echo $match[2]; // url
// echo $match[3]; // type of closing quote
// echo $match[4]; // link text
}
}
?>
// Create DOM from URL or file
$html = file_get_html('http://www.google.com/');
// Find & print all link hrefs
foreach($html->find('a') as $element) echo $element->href . '<br>';

Comment