Jump to content


How do I go about 'grabbing' content from another site?


4 replies to this topic

#1 Tarquin

    Young Padawan

  • Members
  • Pip
  • 67 posts
  • Gender:Male
  • Location:London
  • Interests:I'm a huge Crystal Palace fan (Soccer team in England for you Americans)

Posted 19 November 2006 - 07:53 AM

Well I know its possible, but I don't know how to do it.

I've seen it on some sites, where they show the most recent news from another website, which automatically updates.

How do I do this?

What I want to do, is be able to show the table that is on the bottom right of this page http://news.bbc.co.uk/sport1/hi/football/e...rem/default.stm, on my website. Is there a simple way, or tutorial on this site, which shows me how to do this.


Oh and thanks for your help once again guys :)

Edited by Tarquin, 19 November 2006 - 07:53 AM.


#2 Mr. Matt

    Moderator

  • P2L Staff
  • PipPipPipPip
  • 1,945 posts
  • Gender:Not Telling

Posted 19 November 2006 - 08:19 AM

well its fairly simple to do it.

$page = file_get_contents('http://news.bbc.co.uk/sport1/hi/football/eng_prem/default.stm');

Then do a preg_match_all and look for the rows in that table then store them as you find them and display them on ur site. And as they only update once a week u just need to set a cron job to run on sunday evening.

Matt

#3 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 19 November 2006 - 09:04 AM

You could also look into parsing RSS feeds, im sure quick search for premiership table feeds will get you one to work with. The php category on p2l has some RSS parsing tutorials as well.

#4 Tarquin

    Young Padawan

  • Members
  • Pip
  • 67 posts
  • Gender:Male
  • Location:London
  • Interests:I'm a huge Crystal Palace fan (Soccer team in England for you Americans)

Posted 19 November 2006 - 09:12 AM

Cheers for the help both Matts. (And anyone else who may have replied whilst typing this reply)

I will have a look at your suggestions

#5 Nerve

    Young Padawan

  • Publishing Betazoids
  • Pip
  • 83 posts

Posted 19 November 2006 - 12:01 PM

You could also try something similar to:

$page = file_get_contents('http://news.bbc.co.uk/sport1/hi/football/eng_prem/default.stm');

  $start = '<div class="mxb"><b>Barclays Premiership Table<\/b><\/div>
';
	$end = '<\/table>



<!-- E IINC -->
<!-- E BO -->';

	preg_match( "/$start(.*)$end/s", $page, $match );

echo "$match[1]";






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users