kish89 Posted September 11, 2008 Share Posted September 11, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/123751-solved-html-parsing-help/ Share on other sites More sharing options...
GingerRobot Posted September 11, 2008 Share Posted September 11, 2008 Presumably you own the other site then? Seems a bit pointless to spend time parsing the HTML - wouldn't it just be easier to give the other site (which i'm assume you want to display this data on?) access to the database of the first? Quote Link to comment https://forums.phpfreaks.com/topic/123751-solved-html-parsing-help/#findComment-638986 Share on other sites More sharing options...
sasa Posted September 11, 2008 Share Posted September 11, 2008 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/123751-solved-html-parsing-help/#findComment-639291 Share on other sites More sharing options...
kish89 Posted September 11, 2008 Author Share Posted September 11, 2008 no I don't own remote site, i just uploaded one html page to my web server. @sasa I will try later and let you know if it works. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/123751-solved-html-parsing-help/#findComment-639351 Share on other sites More sharing options...
kish89 Posted September 11, 2008 Author Share Posted September 11, 2008 @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! Quote Link to comment https://forums.phpfreaks.com/topic/123751-solved-html-parsing-help/#findComment-639362 Share on other sites More sharing options...
kish89 Posted September 11, 2008 Author Share Posted September 11, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/123751-solved-html-parsing-help/#findComment-639369 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.