Read an HTML table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nates310
Forum Newbie
Posts: 8
Joined: Sat Sep 23, 2006 11:53 am

Read an HTML table

Post by nates310 »

Is there any way I can read the html from a page that does not belong to me, say a listing of catalog items and get the values from each cell (by looking for the <Td> tags) and then put that info into a table of my own and display it on my page.

I thought of this because with any browser, you can go to a page and view it's source. You can plainly see where the cells are defined and what not, so is there a way of reading that data using php and then putting it into a table of my own. OR, if I want, even uploading it to my own database?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

If available you can use http://de2.php.net/manual/en/function.d ... mlfile.php
But if you're allowed to read/use the data is another story.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

It would not be hard to do using file_get_contents or cURL a few loops and regex :)
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

This is called "scrapping", search for more info.

You can do it by parsing the HTML with a regexp, or with a dom parser, both have pluses and minuses.
Post Reply