Page 1 of 1
was told to post here
Posted: Mon Dec 12, 2005 2:12 pm
by bla5e
How do i get PHP to grab infomation/text from another website??
$data = file_get_contents ('
http://caleague.com/?page=teams&teamid=42842');
Record <b>***this is what you want***</b><br/>
Posted: Mon Dec 12, 2005 2:24 pm
by Chris Corbyn
Please explain what data you're trying to extract? Please also bear in mind that it's illegal to take data from most websites in this way without prior consent from the author.
Regex can pull the data out using
preg_match() but clearly we need an example of what data you want (the parts of the source code from the page in question) along with how you want it.
Read over some posts in this board if you're unsure how to show an example

Posted: Mon Dec 12, 2005 2:46 pm
by shiznatix
its cal-league and its legal to take stuff from them if it is your own clan, many people do it. i told him to post this here and this:
Record <b>***this is what you want***</b><br/>
is the source code. its just whatever is inbetween those 2 bold tags is what he wants (where the ***this is what you want*** is at) but its gotta have the "Record" and the <br/> to find the exact bold tags to take stuff from you know?
But, yes, he should read over the tutorials first and try somtin himself. just trying to clarify it a bit
Posted: Mon Dec 12, 2005 2:50 pm
by Chris Corbyn
Code: Select all
preg_match_all('@Record <b>(.*?)</b><br/>@is', $string, $matches);
print_r($matches);

Posted: Mon Dec 12, 2005 7:24 pm
by bla5e
probably doing this wrong.. but heres what i did
Code: Select all
<?php
$string = file_get_contents('http://www.caleague.com/?page=teams&teamid=42842');
preg_match_all('@Record <b>(.*?)</b><br/>@is', $string, $matches);
print_r($matches);
?>
and heres what happend:
Array ( [0] => Array ( [0] => Record 19-0-0
) [1] => Array ( [0] => 19-0-0 ) )
how do i get rid of the array text?
Posted: Mon Dec 12, 2005 10:20 pm
by John Cartwright
Code: Select all
<?php
$string = file_get_contents('http://www.caleague.com/?page=teams&teamid=42842');
preg_match_all('@Record <b>(.*?)</b><br/>@is', $string, $matches);
echo $matches[1];
?>

Posted: Mon Dec 12, 2005 10:20 pm
by John Cartwright
Code: Select all
<?php
$string = file_get_contents('http://www.caleague.com/?page=teams&teamid=42842');
preg_match_all('@Record <b>(.*?)</b><br/>@is', $string, $matches);
echo $matches[1];
?>

Posted: Mon Jan 16, 2006 12:15 pm
by bla5e
Jcart wrote:Code: Select all
<?php
$string = file_get_contents('http://www.caleague.com/?page=teams&teamid=42842');
preg_match_all('@Record <b>(.*?)</b><br/>@is', $string, $matches);
echo $matches[1];
?>

that just echos "Array" now
Posted: Mon Jan 16, 2006 1:02 pm
by foobar
Code: Select all
<?php
$string = file_get_contents('http://www.caleague.com/?page=teams&teamid=42842');
preg_match_all('@Record <b>(.*?)</b><br/>@is', $string, $matches);
echo $matches[1][0];
?>
...however, you should at least understand PHP *a little* and ask for help instead of showing up out of nowhere and asking for code.
Also, this topic is one month old. Not interested in your own problem?
