Script ดึง Related Keyword จาก Yahoo Overture มาสร้างเป็นหน้าเพจสำหรับปั่นๆ*

เริ่มโดย ggynmsn, 04 สิงหาคม 2007, 02:32:12

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

ggynmsn

 :)

<?php
$keyword=str_replace("_"," ",$mainkeyword);
$keyword=str_replace("%20"," ",$keyword);
$keyword=str_replace(" "," ",$keyword);
$keyword=str_replace("-"," ",$keyword);
include('functions.php');   
$url = 'http://inventory.overture.com/d/searchinventory/suggestion/?term='; . str_replace(" ","+",$keyword) . '&mkt=us&lang=en_US';
$contents = getUrlContents($url);
preg_match_all('/<tr(.*?)<\/tr>/', $contents, $match);
$keyword_row_i = 3;
while($match['1'][$keyword_row_i]  != '') {
$keyword_row_array = explode('</td>',$match['1'][$keyword_row_i]);
$actual_word = strip_tags($keyword_row_array[1]);
$actual_word = str_replace('&nbsp;','',$actual_word);
$keyword_num_array = explode('>',strip_tags($keyword_row_array[0]));
$keyword_num = str_replace('&nbsp;','',$keyword_num_array[1]);
$keyword_display_array[$actual_word] = $keyword_num;
$array_i++;
$keyword_row_i++;
}
      if (count($keyword_display_array) > 0) {
         arsort($keyword_display_array);
         $total = count($keyword_display_array);
         foreach ($keyword_display_array as $key => $val) {
            $keyword_table .= $key . '<BR>';
            $content2=str_replace(' ','-',$key).'.html';
            $key=str_replace("_","+",$key);
             $key=str_replace("%20","+",$key);
             $key=str_replace(" ","+",$key);
             $key=str_replace("-","+",$key);
            
            
         }
         $keyword_table =$keyword_table;
            
      } else {
         $keyword_table .= '<p><strong>There were no results for your keyword search.</strong></p>';
      }
   
?>

<?php echo $keyword_table; ?>



--------------------------------------'functions.php'--------------------------------------
<?php

   
   function getUrlContents($url,$keep_newlines='0') {
      ob_start();
      include_once($url);
      $contents = ob_get_contents();
      ob_end_clean(); 
      if ($keep_newlines == 0) {
         $contents = str_replace("\n",'',$contents);
      }
      return $contents;
   }
   
   function getResultDiv($value,$type='error') {
      // Formats successful or error results whether they are in an array or a snippet.
      if ($type == 'success') {
         $class = 'success-div';
      } elseif ($type == 'test') {
         $class = 'test-div';
      } else {
         $class = 'error-div';
      }
      if (is_array($value)) {
         for ($i = 0; $value[$i] != ''; $i++) {
            $result_div .= '<li>' . $value[$i] . '</li>';
         }
         if ($result_div != '') {
            $result_div = '<div class="' . $class . '"><ul>' . $result_div . '</ul></div>';
         }
      } else {
         if ($value != '') {
            $result_div = '<div class="' . $class . '">' . $value . '</div>';
         }
      }
      return $result_div;
   }
      
   function listArray($array) {
      while ($var = each($array)) {
         printf ("Key <b>%s</b> has the value of: <b>%s</b><br>", $var['key'], $var['value']);
      }
   }
      
   if(!function_exists('str_split')){
      function str_split($str,$length=1){
         $cnt = strlen($str);
         for ($i=0; $i<$cnt; $i+=$length) {
            $array[]= substr($str,$i,$length);
         }   
         return $array;
       }
   }
   
   
?>

ก้ามปู

ใจจ้า เดี๋ยวจะลองเอาไปใช้ดู เดี๋ยวถ้าว่างๆจะลองแก้ดูแล้วเอามาแจกซะเลย 555 ;D
ตอนนี้ผมไม่ค่อยว่างตอบอะไรใครนะครับ เพราะไม่ได้เข้าบอร์ดเลย

golf98765

ขอบคุณครับ

ลองดูละ

ใช้กับ hostgator / localhost ได้

แต่ dreamhost ไม่ได้ครับ


invisibleman

ผมลองบน localhost  ไม่ได้อ่ะ
ผมกำหนด mainkeyword แล้วนะครับ
ขึ้น  There were no results for your keyword search  ตลอดเลย

แต่พอเอาไปทดลองบน host กลับใช้ได้
เป็นเพราะอะไรหรือครับ


ColdMoney

อ้างถึงจาก: invisibleman ใน 04 สิงหาคม 2007, 03:45:54
ผมลองบน localhost  ไม่ได้อ่ะ
ผมกำหนด mainkeyword แล้วนะครับ
ขึ้น  There were no results for your keyword search  ตลอดเลย

แต่พอเอาไปทดลองบน host กลับใช้ได้
เป็นเพราะอะไรหรือครับ




เปลี่ยน function getUrlContents เป็นแบบข้างล่างสิครับ จะ run ได้ทุกโฮสนะ  :)


function getUrlContents($url,$keep_newlines='0'){
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);

      if ($keep_newlines == 0) {
         $contents = str_replace("\n",'',$contents);
      }
 
return $contents;
}   


แล้วอย่าลืมใส่ คำที่ต้องการค้นหาในบรรทักแรกด้วยนะครับเช่น

$mainkeyword="loans";

[direct=https://www.jumnong.com]รับจำนอง[/direct] [direct=https://burapasup.com]รับซื้อบ้าน[/direct] [direct=https://kadsan.com]สินค้าราคาถูก[/direct] [direct=https://checkcheap.com]เปรียบเทียบราคา[/direct]

skywalker252

มันใช้ยังไงเหรอครับ พอดีผมไม่ค่อยรู้เกี่ยวกับภาษา php มากนักน่ะครับ

ผมลอง copy แล้ว paste ใน notepad แล้ว save เป็นไฟล์ index.php
จากนั้นก็ upload ขึ้น Hostgator

โดยผมแทรก $mainkeyword="loans"; เข้าไปเป็น

<?php
[b]$mainkeyword="loans";[/b]
$keyword=str_replace("_"," ",$mainkeyword);
$keyword=str_replace("%20"," ",$keyword);
$keyword=str_replace(" "," ",$keyword);
$keyword=str_replace("-"," ",$keyword);
include(
'functions.php');   
$url 'http://inventory.overture.com/d/searchinventory/suggestion/?term=' str_replace(" ","+",$keyword) . '&mkt=us&lang=en_US';
$contents getUrlContents($url);
preg_match_all('/<tr(.*?)<\/tr>/'$contents$match);
$keyword_row_i 3;
while(
$match['1'][$keyword_row_i]  != '') {
$keyword_row_array explode('</td>',$match['1'][$keyword_row_i]);
$actual_word strip_tags($keyword_row_array[1]);
$actual_word str_replace('&nbsp;','',$actual_word);
$keyword_num_array explode('>',strip_tags($keyword_row_array[0]));
$keyword_num str_replace('&nbsp;','',$keyword_num_array[1]);
$keyword_display_array[$actual_word] = $keyword_num;
$array_i++;
$keyword_row_i++;
}
      if (
count($keyword_display_array) > 0) {
         
arsort($keyword_display_array);
         
$total count($keyword_display_array);
         foreach (
$keyword_display_array as $key => $val) {
            
$keyword_table .= $key '<BR>';
            
$content2=str_replace(' ','-',$key).'.html';
            
$key=str_replace("_","+",$key);
             
$key=str_replace("%20","+",$key);
             
$key=str_replace(" ","+",$key);
             
$key=str_replace("-","+",$key);
            
            
         }
         
$keyword_table =$keyword_table;
            
      } else {
         
$keyword_table .= '<p><strong>There were no results for your keyword search.</strong></p>';
      }
   
?>


<?php echo $keyword_table?>



--------------------------------------'functions.php'--------------------------------------
<?php

   
   
function getUrlContents($url,$keep_newlines='0') {
      
ob_start();
      include_once(
$url);
      
$contents ob_get_contents();
      
ob_end_clean(); 
      if (
$keep_newlines == 0) {
         
$contents str_replace("\n",'',$contents);
      }
      return 
$contents;
   }
   
   function 
getResultDiv($value,$type='error') {
      
// Formats successful or error results whether they are in an array or a snippet.
      
if ($type == 'success') {
         
$class 'success-div';
      } elseif (
$type == 'test') {
         
$class 'test-div';
      } else {
         
$class 'error-div';
      }
      if (
is_array($value)) {
         for (
$i 0$value[$i] != ''$i++) {
            
$result_div .= '<li>' $value[$i] . '</li>';
         }
         if (
$result_div != '') {
            
$result_div '<div class="' $class '"><ul>' $result_div '</ul></div>';
         }
      } else {
         if (
$value != '') {
            
$result_div '<div class="' $class '">' $value '</div>';
         }
      }
      return 
$result_div;
   }
      
   function 
listArray($array) {
      while (
$var each($array)) {
         
printf ("Key <b>%s</b> has the value of: <b>%s</b><br>"$var['key'], $var['value']);
      }
   }
      
   if(!
function_exists('str_split')){
      function 
str_split($str,$length=1){
         
$cnt strlen($str);
         for (
$i=0$i<$cnt$i+=$length) {
            
$array[]= substr($str,$i,$length);
         }   
         return 
$array;
       }
   }
   
   
?>



แต่พอลองกดดูมันขึ้นว่า
Warning: main(functions.php) [function.main]: failed to open stream: No such file or directory in /home/xxxxxx/public_html/xxxxxx/index.php on line 7

แล้วก็มี keyword เกี่ยวกับ loan อยู่ข้างล่าง แต่มันเป็น Text ธรรมดาน่ะครับ เช่น

auto loan
home equity loan
student loan consolidation program
home loan
student loan
payday loan
loan
online loan


ผมต้องแก้ตรงไหนบ้างครับ ? อยากลองเล่นดูน่ะครับ

UnzO

ทำตามนี้คับ  :)


อ้างถึงจาก: ColdMoney ใน 04 สิงหาคม 2007, 08:15:08
อ้างถึงจาก: invisibleman ใน 04 สิงหาคม 2007, 03:45:54
ผมลองบน localhost  ไม่ได้อ่ะ
ผมกำหนด mainkeyword แล้วนะครับ
ขึ้น  There were no results for your keyword search  ตลอดเลย

แต่พอเอาไปทดลองบน host กลับใช้ได้
เป็นเพราะอะไรหรือครับ




เปลี่ยน function getUrlContents เป็นแบบข้างล่างสิครับ จะ run ได้ทุกโฮสนะ  :)


function getUrlContents($url,$keep_newlines='0'){
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);

      if ($keep_newlines == 0) {
         $contents = str_replace("\n",'',$contents);
      }
 
return $contents;
}   


แล้วอย่าลืมใส่ คำที่ต้องการค้นหาในบรรทักแรกด้วยนะครับเช่น

$mainkeyword="loans";



viking

ไม่เป็น php เลยไม่รู้จะใช้ยังไง แต่ขอเก็บไว้ก่อนแล้วกัน

golf98765

อ้างถึงจาก: skywalker252 ใน 04 สิงหาคม 2007, 09:17:01
มันใช้ยังไงเหรอครับ พอดีผมไม่ค่อยรู้เกี่ยวกับภาษา php มากนักน่ะครับ

ผมลอง copy แล้ว paste ใน notepad แล้ว save เป็นไฟล์ index.php
จากนั้นก็ upload ขึ้น Hostgator

โดยผมแทรก $mainkeyword="loans"; เข้าไปเป็น

<?php
$mainkeyword
="loans"// change keyword here.
$keyword=str_replace("_"," ",$mainkeyword);
$keyword=str_replace("%20"," ",$keyword);
$keyword=str_replace(" "," ",$keyword);
$keyword=str_replace("-"," ",$keyword);
include(
'functions.php');   
$url 'http://inventory.overture.com/d/searchinventory/suggestion/?term=' str_replace(" ","+",$keyword) . '&mkt=us&lang=en_US';
$contents getUrlContents($url);
preg_match_all('/<tr(.*?)<\/tr>/'$contents$match);
$keyword_row_i 3;
while(
$match['1'][$keyword_row_i]  != '') {
$keyword_row_array explode('</td>',$match['1'][$keyword_row_i]);
$actual_word strip_tags($keyword_row_array[1]);
$actual_word str_replace('&nbsp;','',$actual_word);
$keyword_num_array explode('>',strip_tags($keyword_row_array[0]));
$keyword_num str_replace('&nbsp;','',$keyword_num_array[1]);
$keyword_display_array[$actual_word] = $keyword_num;
$array_i++;
$keyword_row_i++;
}
      if (
count($keyword_display_array) > 0) {
         
arsort($keyword_display_array);
         
$total count($keyword_display_array);
         foreach (
$keyword_display_array as $key => $val) {
            
$keyword_table .= $key '<BR>';
            
$content2=str_replace(' ','-',$key).'.html';
            
$key=str_replace("_","+",$key);
             
$key=str_replace("%20","+",$key);
             
$key=str_replace(" ","+",$key);
             
$key=str_replace("-","+",$key);
            
            
         }
         
$keyword_table =$keyword_table;
            
      } else {
         
$keyword_table .= '<p><strong>There were no results for your keyword search.</strong></p>';
      }
   
?>


<?php echo $keyword_table?>



--------------------------------------'functions.php'--------------------------------------
<?php

   
   
function getUrlContents($url,$keep_newlines='0') {
      
ob_start();
      include_once(
$url);
      
$contents ob_get_contents();
      
ob_end_clean(); 
      if (
$keep_newlines == 0) {
         
$contents str_replace("\n",'',$contents);
      }
      return 
$contents;
   }
   
   function 
getResultDiv($value,$type='error') {
      
// Formats successful or error results whether they are in an array or a snippet.
      
if ($type == 'success') {
         
$class 'success-div';
      } elseif (
$type == 'test') {
         
$class 'test-div';
      } else {
         
$class 'error-div';
      }
      if (
is_array($value)) {
         for (
$i 0$value[$i] != ''$i++) {
            
$result_div .= '<li>' $value[$i] . '</li>';
         }
         if (
$result_div != '') {
            
$result_div '<div class="' $class '"><ul>' $result_div '</ul></div>';
         }
      } else {
         if (
$value != '') {
            
$result_div '<div class="' $class '">' $value '</div>';
         }
      }
      return 
$result_div;
   }
      
   function 
listArray($array) {
      while (
$var each($array)) {
         
printf ("Key <b>%s</b> has the value of: <b>%s</b><br>"$var['key'], $var['value']);
      }
   }
      
   if(!
function_exists('str_split')){
      function 
str_split($str,$length=1){
         
$cnt strlen($str);
         for (
$i=0$i<$cnt$i+=$length) {
            
$array[]= substr($str,$i,$length);
         }   
         return 
$array;
       }
   }
   
   
?>



แต่พอลองกดดูมันขึ้นว่า
Warning: main(functions.php) [function.main]: failed to open stream: No such file or directory in /home/xxxxxx/public_html/xxxxxx/index.php on line 7

แล้วก็มี keyword เกี่ยวกับ loan อยู่ข้างล่าง แต่มันเป็น Text ธรรมดาน่ะครับ เช่น

auto loan
home equity loan
student loan consolidation program
home loan
student loan
payday loan
loan
online loan


ผมต้องแก้ตรงไหนบ้างครับ ? อยากลองเล่นดูน่ะครับ

แก้โค๊ดให้ละครับ ลองดู ที่บรรทัดแรกของโค๊ดครับ

kewell

อ้างถึงจาก: skywalker252 ใน 04 สิงหาคม 2007, 09:17:01
มันใช้ยังไงเหรอครับ พอดีผมไม่ค่อยรู้เกี่ยวกับภาษา php มากนักน่ะครับ

ผมลอง copy แล้ว paste ใน notepad แล้ว save เป็นไฟล์ index.php
จากนั้นก็ upload ขึ้น Hostgator

โดยผมแทรก $mainkeyword="loans"; เข้าไปเป็น

<?php
[b]$mainkeyword="loans";[/b]
$keyword=str_replace("_"," ",$mainkeyword);
$keyword=str_replace("%20"," ",$keyword);
$keyword=str_replace(" "," ",$keyword);
$keyword=str_replace("-"," ",$keyword);
include(
'functions.php');   
$url 'http://inventory.overture.com/d/searchinventory/suggestion/?term=' str_replace(" ","+",$keyword) . '&mkt=us&lang=en_US';
$contents getUrlContents($url);
preg_match_all('/<tr(.*?)<\/tr>/'$contents$match);
$keyword_row_i 3;
while(
$match['1'][$keyword_row_i]  != '') {
$keyword_row_array explode('</td>',$match['1'][$keyword_row_i]);
$actual_word strip_tags($keyword_row_array[1]);
$actual_word str_replace('&nbsp;','',$actual_word);
$keyword_num_array explode('>',strip_tags($keyword_row_array[0]));
$keyword_num str_replace('&nbsp;','',$keyword_num_array[1]);
$keyword_display_array[$actual_word] = $keyword_num;
$array_i++;
$keyword_row_i++;
}
      if (
count($keyword_display_array) > 0) {
         
arsort($keyword_display_array);
         
$total count($keyword_display_array);
         foreach (
$keyword_display_array as $key => $val) {
            
$keyword_table .= $key '<BR>';
            
$content2=str_replace(' ','-',$key).'.html';
            
$key=str_replace("_","+",$key);
             
$key=str_replace("%20","+",$key);
             
$key=str_replace(" ","+",$key);
             
$key=str_replace("-","+",$key);
            
            
         }
         
$keyword_table =$keyword_table;
            
      } else {
         
$keyword_table .= '<p><strong>There were no results for your keyword search.</strong></p>';
      }
   
?>


<?php echo $keyword_table?>



--------------------------------------'functions.php'--------------------------------------
<?php

   
   
function getUrlContents($url,$keep_newlines='0') {
      
ob_start();
      include_once(
$url);
      
$contents ob_get_contents();
      
ob_end_clean(); 
      if (
$keep_newlines == 0) {
         
$contents str_replace("\n",'',$contents);
      }
      return 
$contents;
   }
   
   function 
getResultDiv($value,$type='error') {
      
// Formats successful or error results whether they are in an array or a snippet.
      
if ($type == 'success') {
         
$class 'success-div';
      } elseif (
$type == 'test') {
         
$class 'test-div';
      } else {
         
$class 'error-div';
      }
      if (
is_array($value)) {
         for (
$i 0$value[$i] != ''$i++) {
            
$result_div .= '<li>' $value[$i] . '</li>';
         }
         if (
$result_div != '') {
            
$result_div '<div class="' $class '"><ul>' $result_div '</ul></div>';
         }
      } else {
         if (
$value != '') {
            
$result_div '<div class="' $class '">' $value '</div>';
         }
      }
      return 
$result_div;
   }
      
   function 
listArray($array) {
      while (
$var each($array)) {
         
printf ("Key <b>%s</b> has the value of: <b>%s</b><br>"$var['key'], $var['value']);
      }
   }
      
   if(!
function_exists('str_split')){
      function 
str_split($str,$length=1){
         
$cnt strlen($str);
         for (
$i=0$i<$cnt$i+=$length) {
            
$array[]= substr($str,$i,$length);
         }   
         return 
$array;
       }
   }
   
   
?>



แต่พอลองกดดูมันขึ้นว่า
Warning: main(functions.php) [function.main]: failed to open stream: No such file or directory in /home/xxxxxx/public_html/xxxxxx/index.php on line 7

แล้วก็มี keyword เกี่ยวกับ loan อยู่ข้างล่าง แต่มันเป็น Text ธรรมดาน่ะครับ เช่น

auto loan
home equity loan
student loan consolidation program
home loan
student loan
payday loan
loan
online loan


ผมต้องแก้ตรงไหนบ้างครับ ? อยากลองเล่นดูน่ะครับ

เป็นเหมือนกันเลยคับ
ไม่ค่อยรู้เรื่อง php อ่ะคับ
ผมแก้ตามที่คุณ Cold Maney บอกแล้วคับแต่ก้อยังไม่ได้ :'( :'( :'(
ไม่รุ้ต้องแก้ตรงไหนอีก รบกวนผู้รู้ช่วยแนะนำทีคับ :-* :-* :-*

okgofun

จะต้องทำให้ได้เดือนละอย่างต่ำ $1,000 แล้วก็ไม่โดนแบน

suaprasong

เห็นบันทัดนี้ไหมครับ

--------------------------------------'functions.php'--------------------------------------

นั่นแหละครับ เอามาทำเป็นอีก 1 ไฟล์ชื่อ 'functions.php'
[direct=http://www.catandkittenstory.com]แมว[/direct]

kewell


au8ust


invisibleman

อ้างถึงจาก: ColdMoney ใน 04 สิงหาคม 2007, 08:15:08
อ้างถึงจาก: invisibleman ใน 04 สิงหาคม 2007, 03:45:54
ผมลองบน localhost  ไม่ได้อ่ะ
ผมกำหนด mainkeyword แล้วนะครับ
ขึ้น  There were no results for your keyword search  ตลอดเลย

แต่พอเอาไปทดลองบน host กลับใช้ได้
เป็นเพราะอะไรหรือครับ




เปลี่ยน function getUrlContents เป็นแบบข้างล่างสิครับ จะ run ได้ทุกโฮสนะ  :)


function getUrlContents($url,$keep_newlines='0'){
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);

      if ($keep_newlines == 0) {
         $contents = str_replace("\n",'',$contents);
      }
 
return $contents;
}   


แล้วอย่าลืมใส่ คำที่ต้องการค้นหาในบรรทักแรกด้วยนะครับเช่น

$mainkeyword="loans";



ทำได้แล้วครับ ขอบคุณมากๆ

skywalker252

ทำได้แล้วครับ ขอบคุณทุกคนมากเลย  ทำเป็น 2 ไฟล์นี่เอง    :-*

aomnaruk


marverick

error functions.php line6 เปลี่ยนเป็น

function getUrlContents($url,$keep_newlines='0'){
   $ch = curl_init();
   $timeout = 0; // set to zero for no timeout
   curl_setopt ($ch, CURLOPT_URL, $url);
   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
   $contents = curl_exec($ch);
   curl_close($ch);
   
      if ($keep_newlines == 0) {
         $contents = str_replace("\n",'',$contents);
      }
    
   return $contents;
   }
แล้วและ mainkeyword แล้ว
เป็นไรหว่า

nynok

[direct=http://www.webpostthai.com]WebPostThai.com ลงโฆษณาฟรี ลงประกาศฟรี ขายของมือสอง[/direct]

Bes

✔แนะนำ Hosting และ VPS ราคาเริ่มต้น 277 บาทฟรี! SSL ซัพพอทคุยง่าย
https://client.hostsevenplus.com/aff.php?aff=396