Someone was nice to write me a script that allows to retrieve data from cross domain site. The PHP looks like this:
<?php
if(isset($_GET['site'])){
$f = fopen($_GET['site'], 'r');
$html = '';
while(strpos($html, 'position1_article_1') === FALSE)
$html .= fread($f, 24000);
fclose($f);
echo $html;
}
?>
Which is saved as proxy.php The Jquery part looks like this:
$(function(){
var site = 'http://www.nu.nl';
$.get('proxy.php', { site:site }, function(data){
var href = $(data).find('.hdtitle').first().children(':first-child').prop('href');
var url = href.split('/');
href = href.replace(url[2], 'nu.nl');
// Put the 'href' inside your div as a link
$('#myDiv').html('<a href="' + href + '" target="_blank">' + href + '</a>');
}, 'html');
});
The problem is that I cant figure out how to get all the 'a' in the body or certain part like h2, h3 etc. Can someone please break it down to me? For instance; what do I have to change in order to get all the href in the page?