Jump to content

[SOLVED] HTML parsing help


kish89

Recommended Posts

Here is the html page from which I need to get data:

http://kish89.pondi.hr/auction.htm

 

I need only fetch data from that middle tables which I translated to english, so you can better understand what I need.

So, script needs to get values from table for Auction,ID,Buyer name, Email, Price, and Quantity.

How to do that?

I assume I need to get this to array, but can I get some example.

 

Thank you in advance!

Link to comment
Share on other sites

try

<?php
$page = file_get_contents('http://kish89.pondi.hr/auction.htm');
$page = html_entity_decode($page);
preg_match_all('|Auction:.*?<font[^>]+>([^<]*).*?<font[^>]+>([^<]*).*?<tr.*?<tr.*?<span><[^>]+>([^<\s]*).*?mailto:([^"\']+).*?<font[^>]+>\s*([0-9,]*).*?<font[^>]+>\s*([0-9,]*)|s', $page, $out);
//print_r($out);
foreach ($out[0] as $k => $v){
echo 'Aukcija: ', $out[1][$k], "<br />\n";
echo 'ID: ', $out[2][$k], "<br />\n";
echo 'Ime: ', $out[3][$k], "<br />\n";
echo 'E-mail: ', $out[4][$k], "<br />\n";
echo 'Cijena: ', $out[5][$k], "<br />\n";
echo 'Kolicina: ', $out[6][$k], "<hr />\n";
}
?>

Link to comment
Share on other sites

Everything is ok! thank you.

problem was in :

preg_match_all('|Auction:.*?<font[^>]+>([^<]*).*?<font[^>]+>([^<]*).*?<tr.*?<tr.*?<span><[^>]+>([^<\s]*).*?mailto:([^"\']+).*?<font[^>]+>\s*([0-9,]*).*?<font[^>]+>\s*([0-9,]*)|s', $page, $out);

 

I've added |si .

Just one question, how to add extracted data to mysql.

Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.