Jump to content

PHPQuery - Parsing Data


xPulsarx

Recommended Posts

Hi Guys,

 

I'm working ona  website at the moment thats like a "search" enging type website, just an idea i have in my head but in order to do that I need this site to "Parse" data from another website. I have been told that PHPQuery is so far the best one to use. I have managed to parse data from eBay quite easily but when it comes to a site like this..

www.dstore.com.au 

 

It has been hard, there code is so messy I don't know how they can run it like that, mentioning that, I've seen worse...

 

Basically if you look at this..

 

http://dstore.com.au/home/search/quick/100,0,12,00.html?search_term=Jim+Beam&utm_campaign=dStoreSearch&ps=1

 

I want to be able to grab the ( Picture, Link, Title & Price )

 

Using PHPQuery atm, I am doing this

 

$dstoreprod = $dstore->find( "table.top_panel + div table" );
$dstoreprod = $dstoreprod->find( "table table[cellspacing=0]" );
$dstoreprod = $dstoreprod->find( "tr" );

$dstoreprod = $dstoreprod->slice( 1, 6 );
foreach ( $dstoreprod as $row )
{
$image = pq( $row )->find( "td a img" )->attr( "src" );
$title = pq( $row )->find( "td a strong" )->text();
$title_link = pq( $row )->find( "td a" )->eq( 1 )->attr( "href" );
$price = pq( $row )->find( "td[valign=middle]")->text();

echo "<img src=\"". $image ."\"></img>  ";
echo "<a href='" . $title_link ."'>". $title ."</a>";
echo "&nbsp $price";
echo "<br />";
}

 

However it isn't working, I have tried many different routines and still cannot get it to work..

 

I guess my main question actually is, am I missing something? or is there an easier way to grab this sort of information from websites?

 

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/149635-phpquery-parsing-data/
Share on other sites

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.