【问题标题】:how to create a backlink checker如何创建反向链接检查器
【发布时间】:2014-06-08 06:03:00
【问题描述】:

我正在尝试在 codeigniter 中获得结果,但此代码没有输出任何内容。 有没有人在codeigniter中有解决方案。 我需要一些提示。

$url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
     . "q=Paris%20Hilton&userip=USERS-IP-ADDRESS";

// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, /* Enter the URL of your site here */);
$body = curl_exec($ch);
curl_close($ch);

// now, process the JSON string
$json = json_decode($body);
// now have some fun with the results...

【问题讨论】:

  • 你想要的输出是什么?实际输出是多少?请提供更多详细信息。
  • 试试 echo curl_error($ch);在 curl_close($ch) 之前;查看任何卷曲错误

标签: php json codeigniter


【解决方案1】:

我有一个使用 curl 的反向链接检查器,你输入你的网站,你想检查的网站可能是你可以使用的

<div id="content">

  <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

      <label>Target URL</label><input type="text" name="url" class="url" value="http://www." /><br/>

          <label>Your URL &nbsp;</label>  <input type="thereurl" name="thereurl" class="url" value="http://www."/>

      <input type="hidden" name="secureurl" value="1"/>

      <input type="submit" name="query" value="Check Links" class="button"/>

    </form>

<?php

  if(isset($_POST['query']))
  {

    $error=1;                      

    $target_url = $_POST['url'];

    $url2=$_POST['thereurl'];

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

$xpath = new DOMXPath($dom);

$hrefs = $xpath->evaluate("/html/body//a");

for ($i = 0; $i < $hrefs->length; $i++) {

  $href = $hrefs->item($i);

  $url = $href->getAttribute('href');

  $rel = $href->getAttribute('rel');

  $length=strlen($url2);

  $changethis=substr($url2,0 , $length);

  $length2=strlen($url);

  $changethis2=substr($url,0 , $length);

  if($changethis2==$changethis)
  {

      echo "<br />Link: $url <strong>$rel</strong> was found backlinking your URL";

      $error=0;

  }
} //end loop

if($error <>0) {
  echo "No Backlink Was Found";        
}
echo "</div>";

  }//end if isset



?>

</div>

希望你可以利用其中的一些

【讨论】:

  • 您提交的代码运行成功,但我正在本地服务器上测试它给了我一个主机错误如何在本地服务器上运行它我尝试了很多但它没有...建议一些事情
  • 像魅力一样工作...... :) 谢谢 Truckbloor
  • 要在目标网址您的网址中输入什么值
  • 嗨 Kailas,目标网址是您认为反向链接应该在的网站的网址
猜你喜欢
  • 2015-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多