Page 1 of 1
Grab data from URL
Posted: Thu Mar 17, 2005 10:28 pm
by bladecatcher
G'day All,
I want to grab data from a public web site parse it and add it to my page (with permission of coarse).
A starting point would be how to grab the page, yes?
Where and what am I looking for?
Thanking you in advance,
bladecatcher
Start here
Posted: Thu Mar 17, 2005 10:33 pm
by neophyte
Posted: Thu Mar 17, 2005 10:37 pm
by hongco
i believe it involves several things. you wanted to know the structures of that page in order to find out where on that page you want to get the info from.
some useful functions such as:
file(), explode() etc...
Posted: Fri Mar 18, 2005 12:27 am
by bladecatcher
G'day,
Thank you for your replies.
file_get_contents looks like what I'm after but ...
Is it a php4 function?
I get:
Fatal error: Call to undefined function: file_get_contents() in /var/www/xxx/weather.php on line 5
tia
bladecatcher
Posted: Fri Mar 18, 2005 12:47 am
by John Cartwright
file_get_contents
(PHP 4 >= 4.3.0, PHP 5)
you can also try
fopen(),
fread(),
fclose()
Posted: Fri Mar 18, 2005 12:59 am
by bladecatcher
yep, I saw that.
sorry I should have been more explicite
I'm interpreting that as > PHP 4.3.0 ???
I've found phpinfo.php will run that and see.
phpinfo says
Posted: Fri Mar 18, 2005 1:05 am
by bladecatcher
damn, PHP Version 4.1.2
Thanks for the start though, I'll look at the longer route.
Any alternative suggestions?
Thanks very much guys
btw, I got the version by running a file phpiinfo.php which I found easily through a google search.
Posted: Fri Mar 18, 2005 1:14 am
by John Cartwright
Posted: Fri Mar 18, 2005 2:47 am
by bladecatcher
Thanks All,
so far I've got:
Code: Select all
$wpage = fopen("http://www.site.com.au/cgi-bin/script.pl?ID1.txt", "r");
while(!feof($wpage))
{
$output = fgetss($wpage, 1024);
echo ("$output<br />");
}
fclose($wpage);
Now I need to search $wpage for a string (mystring) then output the next 3 lines.
I could use strstr on each line however is there a function to find the first occurance of a string in the file?
tia
bladecatcher
Posted: Fri Mar 18, 2005 8:17 am
by feyd
strpos
Posted: Sat Mar 19, 2005 12:14 am
by bladecatcher
Thank you very much.