I am scraping a news website and they also provide a link to a whole article, however href for those links look like this:
/news-features/8/news-headlines/103818/these-pupils-deserve-better
So in order for the link I need to dynamically add:
http://www.oldham-chronicle.co.uk
So the whole link would be:
http://www.oldham-chronicle.co.uk/news-features/8/news-headlines/103818/these-pupils-deserve-better
As you can assume there is more then 1 article however the part of the link I need to add is the same. Therefore for each one of them I need to add it.
At the moment I have:
$("a").each(function(){
this.href=this.href.replace("http://www.oldham-chronicle.co.uk");
});
however my link looks like this:
href="http://localhost/news-features/8/news-headlines/103818/these-pupils-deserve-better"
Which is wrong, how can that be solved?