Jump to content

[SOLVED] reading partial code from external site


daveh33

Recommended Posts

Hi,

 

I am trying to write a script for my website to get an article from an external website. The external website has the article in a set of tags <roottag> & </roottag>

 

The code I am using is

$page = file_get_contents($url);
preg_match_all("/<roottag>.+<\/roottag>/", $page, $matches);
print_r($matches);

 

when this code runs the below is output: -

 

Array ( [0] => Array ( ) )

 

I've not used this function in php and am a bit stuck! so any help is really appreciated

<?

$url = "http://www.thesun.co.uk/sol/homepage/sport/other_sports/racing/1142207/Templegates-racing-tips.html";
$page = file_get_contents($url);

// echo $page;

preg_match_all("/<roottag>(.+?)<\/roottag>/", $page, $matches);
print_r($matches);


?>

try:

 

<?php
$url = "http://www.thesun.co.uk/sol/homepage/sport/other_sports/racing/1142207/Templegates-racing-tips.html";
$page = file_get_contents($url);
preg_match_all("~\<roottag\>(.+?)\<\/roottag\>~s", $page, $matches);
print_r($matches);
?>

 

edit: Late

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.