0

I'm trying to do a fun little project where I basically take headlines for ex from a news site, scrape it/mirror it onto an additional site using php, and then have that data that is displayed on the new site actually be clickable links to the original site. if that's a bit confusing, let me show an example.

http://www.wilsonschlamme.com/test.php Right there, I'm using php to scrape all data from the antrimreview (local michigan news site) contained in a < span=class >. I chose span class, because that's where their headlines are located. I'm just using antrim for testing purposes, I have no affiliation with them.

*What I'm wondering is, and what I don't know how to do, is actually make these headlines that are re displaying on my test site, as clickable links. In other words, retain the < a href > of these headlines that contain clickable links to the full articles. Put differently, on the antrim website, those headlines are clickable links to full pages. When mirrored on my test website presently, there's clearly no links, because there's nothing grabbing the data.

Does anyone know how this could be done? or any thoughts? Would really appreciate it, this is a fun project, just lacking the knowledge on how to complete it.

Oh and i know the pokemon references are lolsy down below. It's because I'm working with code originally from a tutorial somewhere lol:

<?php
$html = file_get_contents('http://www.antrimreview.net/'); //get the html 
returned from the following url

$pokemon_doc = new DOMDocument();

libxml_use_internal_errors(TRUE); //disable libxml errors

if(!empty($html)){ //if any html is actually returned

$pokemon_doc->loadHTML($html);
libxml_clear_errors(); //remove errors for yucky html

$pokemon_xpath = new DOMXPath($pokemon_doc);

//get all the h2's with an id
$pokemon_row = $pokemon_xpath->query('//span[@class]');

 if($pokemon_row->length > 0){
  foreach($pokemon_row as $row){
      echo $row->nodeValue . "<br/>";
  }
 }
 }
 ?>
Masteryogurt
  • 199
  • 4
  • 14

1 Answers1

-1

I actually found it simple to just use a CNN rss feed for ex, using surfing-waves to generate the code. thx for the suggestions anyway.

Masteryogurt
  • 199
  • 4
  • 14