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
https://forums.phpfreaks.com/topic/123751-solved-html-parsing-help/
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";
}
?>

@sasa

 

Oh thank you very much! code extracted what I need.

So, it's working on example I gave you, but its not working on real thing.(http://kish89.pondi.hr/aukcija.htm )

So can you please change code regarding to this source.

And how to add to code so this values which are extracted INSERTS to mysql database.

Thank you again!

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.