PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The page mostly displays fine, except the only part that is not shown is the Amazon Sales Ranking. Do you know why the sales ranking doesn't show? You see the difference in the two pages at
If you notice carerfully you'll find many things are missing from the actual site in your page.
One is the 5 stars and the text 5 cutomer reviews on top that you mentioned.
You'll also notice that the Amazon link has Web Design for Teens (Paperback) while your has Web Design for Teens - the (Paperback) text is missing !
This is because Amazon has either used Javascript to dynamically populate the page text or some method of finding out the Server side from where exactly is the page being called.
Same issue in Alexa - everything except the ranking and traffic details are shown when pulled using code.
require_once('simpletest/browser.php');
// new browser
$ua =& new SimpleBrowser;
// fake User-Agent
$ua->addHeader('User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6');
// request page
$ua->get('http://www.amazon.com/exec/obidos/tg/detail/-/1592006078/qid=1104460675/sr=8-1/ref=sr_8_xs_ap_i1_xgl14/104-6302267-7125537?v=glance&s=books&n=507846');
// this is what we get
echo $ua->getContent();
(Ps: I it's at least remarkable, as an author of a webdesign book, that the html on your website(s) doesn't validate.)
timvw - How to send a header like
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
in fsock or Curl or any other direct method ?
fwrite("User-Agent: anjanesh browser rules the world\n");
Btw, instead of inventing a UserAgent string, you could use the one your browser sends to the script that is going to retrieve the data Code could look like: