was told to post here
Moderator: General Moderators
was told to post here
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/>
$data = file_get_contents ('http://caleague.com/?page=teams&teamid=42842');
Record <b>***this is what you want***</b><br/>
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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
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
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
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
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
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Code: Select all
preg_match_all('@Record <b>(.*?)</b><br/>@is', $string, $matches);
print_r($matches);probably doing this wrong.. but heres what i did
and heres what happend:
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);
?>how do i get rid of the array text?Array ( [0] => Array ( [0] => Record 19-0-0
) [1] => Array ( [0] => 19-0-0 ) )
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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];
?>- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
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" nowJcart 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]; ?>
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?