ThaiSEOBoard.com

พัฒนาเว็บไซต์ => Programming => ข้อความที่เริ่มโดย: comatac3 ที่ 26 ตุลาคม 2011, 13:59:16



หัวข้อ: ปรึกษาหน่อยครับ php google suggust
เริ่มหัวข้อโดย: comatac3 ที่ 26 ตุลาคม 2011, 13:59:16
โค๊ด:
function text_between($start,$end,$string) {
  if ($start != '') {$temp = explode($start,$string,2);} else {$temp = array('',$string);}
  $temp = explode($end,$temp[1],2);
  return $temp[0];
}
function gsscrape($keyword) {
  $keyword=str_replace(" ","+",$keyword);
  global $kw;
  $data=file_get_contents('http://clients1.google.com/complete/search?hl=en&gl=uk&q='.$keyword);
  $data=explode('[',$data,3);
  $data=explode('],[',$data[2]);
  foreach($data as $temp) {
  $kw[]= text_between('"','"',$temp);
  }
}
#simple to use, just use yourscriptname.php?keywords
if ($_SERVER['QUERY_STRING']!='') {
  gsscrape($_SERVER['QUERY_STRING']);
  foreach ($kw as $keyword) {
  gsscrape($keyword);
  }
}

#all results are in array $kw...
print_r($kw);

พอดีเจอโค้ดนี้ เป้น google suggest ผลออกมาเป็น
Array (
  • => hotmail [1] => hotmail.fr [2] => hotmail news [3] => hotmail.se [4] => hotmail down [5] => hotmail.com.br

อยากให้ออกมาเป็น
hotmail
hotmail.fr
hotmail news
hotmail.se
hotmail down
hotmail.com.br

ต้องทำยังไงเหรอครับ พอดีไม่มีความรู้เรื่องนี้เลยครับ

ขอบคุณครับ



หัวข้อ: Re: ปรึกษาหน่อยครับ php google suggust
เริ่มหัวข้อโดย: comatac3 ที่ 26 ตุลาคม 2011, 14:10:08
มีใครช่วยได้บ้างไหมครับ  :'(


หัวข้อ: Re: ปรึกษาหน่อยครับ php google suggust
เริ่มหัวข้อโดย: Etaba ที่ 26 ตุลาคม 2011, 14:57:13
แก้ออก:สงสัยจะผิด