Jump to content

curl help


darkfreaks

Recommended Posts

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);

 

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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¢—

 

 

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.