Jump to content

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

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?

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.

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.