Jump to content

[SOLVED] Parse out list from amazon.com ?


mini_

Recommended Posts

If you look on

http://www.amazon.com/gp/bestsellers/music/ref=pd_ts_c_th_head/002-5957247-9688012?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=right-4&pf_rd_r=1GH6HBJ7B31EPCC5K6XK&pf_rd_t=101&pf_rd_p=259704501&pf_rd_i=5174

it shows the best sellers music albums om amazon.com

Is it possible to use some kind of regexp to parse out the top 25 list shown on the page?

Have been trying for the hole day without any success  :o

 

Any help at all would make me very glad :)

Link to comment
Share on other sites

<pre>
<?php

$url = 'http://www.amazon.com/gp/bestsellers/music/ref=pd_ts_c_th_head/002-5957247-9688012?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=right-4&pf_rd_r=1GH6HBJ7B31EPCC5K6XK&pf_rd_t=101&pf_rd_p=259704501&pf_rd_i=5174';
$page = file_get_contents($url);
preg_match_all('%<strong.+?><a.+?>([^>]+)</a></strong>\s*<br />\s+~\s+((??!\(Artist\))[^<])+)%', $page, $matches, PREG_SET_ORDER);
// Toss full matches.
foreach ($matches as &$match) {
	array_shift($match);
}
print_r($matches);

?>
</pre>

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.