當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crawler::run方法代碼示例

本文整理匯總了PHP中Crawler::run方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crawler::run方法的具體用法?PHP Crawler::run怎麽用?PHP Crawler::run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Crawler的用法示例。


在下文中一共展示了Crawler::run方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Crawler

<?php

require_once '../vendor/autoload.php';
require_once 'crawler.php';
require_once 'CKMoz.php';
require_once 'auth/auth.php';
$startURL = $_POST['url'];
$urls = [];
$crawler = new Crawler($startURL, 3);
$urls = $crawler->run();
var_dump($urls);
die;
$encoded = json_encode($urls);
header('Content-type: application/json');
exit($encoded);
if (!is_array($urls)) {
    throw new Exception("There's no URL's to make the consult.");
}
$groups = array_chunk($urls, 10);
$metricQ = new CKMoz(ACCESS_ID, SECRET_KEY);
$cols = array('title', 'canonURL', 'ExEquityLinks', 'links', 'mozRankURL', 'mozRankSubDomain', 'httpCode', 'pageAuth', 'domainAuth');
$result = array();
foreach ($groups as $group) {
    var_dump($group);
    exit;
    $rs = $metricQ->batchedQuery($group, $cols);
    // if the result is an error of authentication
    if ($rs->code == 401) {
        header('Content-type: application/json');
        exit($rs->data);
    }
開發者ID:alfchee,項目名稱:TestDomPDF,代碼行數:31,代碼來源:CrawlerController.php

示例2: Crawler

<?php

require 'class/Crawler.php';
require 'class/Utils.php';
$crawler = new Crawler();
$crawler->run();
開發者ID:hadikcz,項目名稱:PrntscrRandomDownloader,代碼行數:6,代碼來源:run.php

示例3: jsReload

     print_r($districts);
     jsReload();
     exit;
 } else {
     //Crawl wards
     foreach ($province['districts'] as $districtId => $district) {
         $excerptDistricts = ['318' => 1, 471 => 1, 498 => 1, 755 => 1];
         if (!empty($excerptDistricts[$districtId])) {
             continue;
         }
         if (!isset($district['wards']) || count($district['wards']) < 1) {
             echo '<pre>';
             echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
             $url = 'http://www.gso.gov.vn/danhmuc/dmhc.aspx?macap2=' . $districtId;
             $crawler = new Crawler($url);
             $listHtml = $crawler->run();
             $pattern = '/<td align=\'left\' ><font color=\'blue\'>([0-9]{5})<\\/a><\\/td><td align=\'left\' id=\'link\' ><font color=\'blue\'>([^<>]*)<\\/td>/';
             preg_match_all($pattern, $listHtml, $matches);
             //    print_r($matches);
             $wards = [];
             foreach ($matches[1] as $k => $wardId) {
                 $wards[$wardId] = ['name' => $matches[2][$k]];
             }
             $_SESSION['provinceList'][$provinceId]['districts'][$districtId]['wards'] = $wards;
             echo 'Crawled ', htmlentities($province['name']), ' -> ', htmlentities($district['name']), '<br>';
             if (count($wards) < 1) {
                 echo "<br>Da bi chan boi site gov. Reload lai sau 5'</br>";
                 jsReload(120000);
             }
             print_r($wards);
             jsReload();
開發者ID:vantrieuou,項目名稱:vietnam-administrative-units,代碼行數:31,代碼來源:index.php


注:本文中的Crawler::run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。