Jump to content

HELP! Can't extract info from site


limareros

Recommended Posts

Hello, sorry if this is the wrong area for this topic, but I am new here.

 

I have a problem.

 

I need to extract some info from a website, but it seems that I can't do it.

 

I need to know the number of items in stock in a online store.

 

The price and name of the item can be easily extracted, however, for me to check the stock I have to place '99' in the quantity box and click 'Add to Cart'. If the amount gets changed, it means that they dont have 99 items, and then the extracting of the number of items in stock would be easy.

 

The problem is that the 'Add to Cart' button is actually a javascript function, so I can't call it with curl.

 

Using HTTP Live Headers addon I figured that by clicking the button did this:

 

-http://secure.newegg.com/Shopping/AddToCart.aspx?Submit=Add&ItemList=N82E16882597038%7C99&OptionItemList=&PreItemList=&EWTList=0_N82E16882597038

 

then

 

-http://www.newegg.com/Shopping/ShoppingItem.aspx?ItemList=N82E16882597038

 

and finally

 

-http://secure.newegg.com/Shopping/ShoppingCart.aspx?submit=ChangeItem

 

 

In the end it should give the cart page with the 99 items added, but instead it is empty.

 

I need help please.

 

this is one of the codes I tried so far:

 

$url="http://secure.newegg.com/Shopping/AddToCart.aspx?Submit=Add&ItemList={$itemn}%7C99&OptionItemList=&PreItemList=&EWTList=0_{$itemn}";

$url2= "http://www.newegg.com/Shopping/ShoppingItem.aspx?ItemList={$itemn}";

$url3="http://secure.newegg.com/Shopping/ShoppingCart.aspx?submit=ChangeItem";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; da; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11');
$contents2 = curl_exec($ch);
echo $contents2;



curl_setopt($ch, CURLOPT_URL, $url2);
$contents2 = curl_exec($ch);
echo $contents2;

curl_setopt($ch, CURLOPT_URL, $url3);
$contents2 = curl_exec($ch);
echo $contents2;

 

 

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.