Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

extract HTML

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

extract HTML

Postby Smoker » Wed Mar 19, 2003 4:21 am

I would like to read an html document from a website into an array or variable of some sort in php. My goal is to have a web page that has dynamic data from another page.
Smoker
New php-forum User
New php-forum User
 
Posts: 6
Joined: Wed Mar 19, 2003 4:18 am

Postby Oleg Butuzov » Wed Mar 19, 2003 6:19 am

questions ?
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Xerpher » Wed Mar 19, 2003 8:51 am

Try fread();
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada

Postby Smoker » Wed Mar 19, 2003 5:07 pm

ok maybee I wasnt specific enough. Lets say I want to extract the html from yahoo into an array.
What i want is something like
$array = http://www.yahoo.com
then i can go through and parse the html to get the desired text.

what is the best way to do this?
Smoker
New php-forum User
New php-forum User
 
Posts: 6
Joined: Wed Mar 19, 2003 4:18 am

Postby Smoker » Wed Mar 19, 2003 5:49 pm

I tried fread with $filename = http://www.yahoo.com. It didnt work
Smoker
New php-forum User
New php-forum User
 
Posts: 6
Joined: Wed Mar 19, 2003 4:18 am

Postby Smoker » Wed Mar 19, 2003 6:04 pm

Ok im alot closer to my solution. I can read in a html page from the web into an array. But what i need to do is read in the html output from a php page.
Smoker
New php-forum User
New php-forum User
 
Posts: 6
Joined: Wed Mar 19, 2003 4:18 am

Postby Xerpher » Wed Mar 19, 2003 7:50 pm

No offence, but learn some basics of php. The questions you are asking are from the absolute most basic tutorials. To output the array use echo() or print()
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada

Postby Smoker » Thu Mar 20, 2003 1:05 am

No offence taken, I once again misstated my question. I know how to print an array while in php. What I want to do is extract information from a php generated page. For instance lets say I have a page http://www.mydomain.com/test.php This page contains a print statement that prints "Hello world!". I want to navigate to this page through php and extract the generated html. But if I make the filehandle of a fread statement http://www.mydomain.com/test.php it doesnt output anything. Probably because my php script doesnt have permission to read the php script of another page. But im not interested in the script just the html that that script generates. Heres an example of the code that im working on. This code reads a html page from the internet and then spits it right back out.
Code: Select all
<?php
   $filename = "http://www.gnu.org/copyleft/gpl.html";
   $handle = fopen ($filename, "r");
   $contents = fread ($handle, 5000);
   fclose ($handle);
   echo $contents;
?>

Notice the page im reading is an html page so it works. I want to be able to do the same with the html generated by a php page.
The reason I want to do this is i want to create a page for some people who dont want to give up their current web page system(which alows them to update the site rather easily with no programming skill). So what I want to do is create a php shell that will extract the information from their current page and then go into whatever format I choose. Their using tiki wiki if you are familiar with that. Which while it is easy to use doesnt provide enough customizability for my tastes.
Thanks for all your help so far everyone
-Smoker
Smoker
New php-forum User
New php-forum User
 
Posts: 6
Joined: Wed Mar 19, 2003 4:18 am

Postby Xerpher » Thu Mar 20, 2003 10:00 am

I'm not sure how to help, I just tried that code with the html file you specified, then a php file I had and they both worked... could you maybe give more details of what you are doing specifically?
Xerpher
New php-forum User
New php-forum User
 
Posts: 164
Joined: Tue Aug 27, 2002 8:25 pm
Location: Ontario, Canada


Return to PHP coding => General

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron