Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- body {
- font:8pt tahoma;
- margin:4;
- color:#330000;
- background:#99ff00; }
- a {
- text-decoration:none;
- color:#009999;
- }
- .r {
- font:8pt tahoma bold;
- margin:2;margin-top:4; }
- </style>
- <body>
- <?php
- $q = $_GET['key'];
- if (!empty($q)) {
- $q = stripslashes($q);
- $hasil = googling($q,$m);
- echo "<h2> search results: $q<hr size=1 noshade>\n";
- }
- echo $hasil;
- echo "<br><br>";
- ?>
- <hr size=1 noshade>
- <center>
- <form method="GET">
- Input Keyword: <input type="text" name="key" size=50 value="<?php echo htmlentities($q); ?>">
- <input type="submit" value="Cari">
- </form>
- </center>
- <hr size=1 noshade>
- <?php
- function googling($key,$max) {
- $key = urlencode($key);
- $num = 100;
- $c = 0;
- for ($p=0;$p<=1000;$p+=10) {
- $rez = httpquery("http://www.google.com/search?q=".$num."&hl=id&q=".$key."&start=".$p."&sa=N",5);
- #$pattern = '#<h3 class="r"><a href="([^"]*)" class#i';
- $pattern = '#<h3 class="r"><a href="([^"]*)"#i';
- $count = preg_match_all($pattern,$rez,$matches,PREG_SET_ORDER);
- if ($count == 0) { return $h; }
- else {
- for ($i = 0;$i < $count;$i++) {
- $urlz = urldecode($matches[$i][1]); $desc = $matches[$i][2];
- $c++;
- }
- }
- }
- return $h;
- }
- function httpquery($url,$timeout) {
- $aurl = explode ("/",$url);
- $host = $aurl[2];
- $ruri = "/".join("/",array_slice ($aurl,3));
- $port = 80;
- $sock = fsockopen ($host,$port,$errno,$errstr,$timeout);
- if ($sock) {
- $out = "GET $ruri HTTP/1.1\r\n".
- "Host: $host\r\n".
- "Accept: */*\r\n".
- "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 \r\n".
- "Connection: Close\r\n\r\n";
- fputs($sock,$out);
- while (!feof($sock)) {
- $rez .= @fgets($sock,512); }
- fclose($sock);
- }
- return $rez;
- }
- ?>
- </body>
- <?php die(); ?>
Advertisement
Add Comment
Please, Sign In to add comment