limareros Posted September 15, 2010 Share Posted September 15, 2010 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; Quote Link to comment https://forums.phpfreaks.com/topic/213445-help-cant-extract-info-from-site/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.