darkfreaks Posted April 26, 2010 Share Posted April 26, 2010 how would i curl a website like this http://www.bankofwow.com/cart.php?target=category&category_id=7873 and return Name of Server | Price | cheapest price | buy now any examples? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 26, 2010 Author Share Posted April 26, 2010 can i do something like this? but how would i make it grab just the cheapest price and the server and return it? $target_url = "http://www.bankofwow.com/cart.php?target=category&category_id=7873"; $userAgent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)'; // make the cURL request to $target_url $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_FAILONERROR, true); #curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $html= curl_exec($ch); if (!$html) { echo "<br />cURL error number:" .curl_errno($ch); echo "<br />cURL error:" . curl_error($ch); exit; } // parse the html into a DOMDocument $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); Quote Link to comment Share on other sites More sharing options...
Kidd13 Posted April 26, 2010 Share Posted April 26, 2010 This right here will get the pages source $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.bankofwow.com/cart.php?target=category&category_id=7873'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); $results = curl_exec ($ch); now I'm still a little nooby when it comes to string manipulation cause i don't use it often but this is the method i would use because i find it very easy to understand $tempname = explode(' class="SidebarItems">',$results); for ($i = 1; $i < sizeof($tempname); $i++) { $name = explode('</FONT></a></td>',$tempname[$i]); $names[$i] = $name[0]; } What I'm basically doing there is splitting the page by the information in the source that is constant and comes before the name there are other methods of doing this. but this is the way i understand it. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 26, 2010 Author Share Posted April 26, 2010 thgat returns completely blank Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 26, 2010 Author Share Posted April 26, 2010 also i want to put all the ID's into an array than put the arrayed id's into the url and have it returl all the id's without having to put each url in a thousand times over. Quote Link to comment Share on other sites More sharing options...
brianlange Posted April 26, 2010 Share Posted April 26, 2010 We I perform the curl request I get a bunch of jibberish returned. If I could get the html I'm sure I could parse it to get what you want. Here's what I am seeing ‹í=ërÚÈÒ¿×Uy‡‰rÛµw;†ÆNì=vÌYWΩ-j€I«‹Y6›úÞòëž];ö&9eg×FBÓÓÓÓÝÓÝÓÓ:|¾·Gþ;`Íøìí5žmžö.Îá/|âßM_4ñïÅI¯I¦®kí±?<í¦®´LÃe†»×[XL!CqUW\ö§››º3ý5N©í0·®9æ^VÞßSÑIï¬w~ÒhA7¹º¼"ïL}”!üš9np‹&›Ì†AN>t.ÉiêºF!;Ì ØŒ¹”tÆêÊ5[ÌM{äDÐòNææœL¢²ÔdÄœ¡ Y®f‘VqÔHWsYöŠ‘)½aIJTÛ¶6dNöÈ[„÷ƦMºTgd®¹SÞn€mfßÀÄðu\¼7bºvÃìöBuÇ$–mÞh#FÆ6c¢— Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 26, 2010 Author Share Posted April 26, 2010 you know you could just view the source code and it would give ya the html Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 26, 2010 Author Share Posted April 26, 2010 does anyone know how i would curl it without all the mumbo jumbo stuff appearing? Quote Link to comment Share on other sites More sharing options...
teamatomic Posted April 27, 2010 Share Posted April 27, 2010 Its gzipped. curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate"); HTH Teamatomic Quote Link to comment 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.