Created
September 23, 2009 22:23
-
-
Save antimatter15/192346 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function search_wolframalpha($query){ | |
$url2 = 'http://www.wolframalpha.com/input/?i='.urlencode($query); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_POST, 0); | |
//curl_setopt($ch, CURLOPT_REFERER, $ref); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_AUTOREFERER, 1); | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 60); | |
curl_setopt($ch, CURLOPT_MAXREDIRS, 2); | |
//curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_URL, $url2); | |
$r = curl_exec($ch); | |
$doc = new DOMDocument(); | |
@$doc->loadHTML($r); | |
$results = $doc->getElementById("results"); | |
foreach($results->getElementsByTagName("img") as $img){ | |
$src = $img->getAttribute("src"); | |
if($src != "/images/loadingdots.gif"){ | |
echo "<img src='".$src."'><br>"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment