当前位置: 首页>>代码示例>>PHP>>正文


PHP phpQuery::newDocumentFile方法代码示例

本文整理汇总了PHP中phpQuery::newDocumentFile方法的典型用法代码示例。如果您正苦于以下问题:PHP phpQuery::newDocumentFile方法的具体用法?PHP phpQuery::newDocumentFile怎么用?PHP phpQuery::newDocumentFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpQuery的用法示例。


在下文中一共展示了phpQuery::newDocumentFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testFind

 public function testFind()
 {
     $htmlPath = BASE_PATH . '/samples/zingmp3_playlist.html';
     $document = phpQuery::newDocumentFile($htmlPath);
     $matches = $document->find('.item-song a.fn-name');
     $item = pq($matches[0]);
     $this->assertEquals('http://mp3.zing.vn/bai-hat/The-First-Noel-David-Archuleta/IW6UUBOW.html', $item->attr('href'), "Attribute and Value are not found");
 }
开发者ID:tungnguyenson,项目名称:slackpi,代码行数:8,代码来源:PhpQueryTest.php

示例2: qihoo

 public function qihoo()
 {
     set_time_limit(0);
     import('Org.JAE.QueryList');
     header("Content-type: text/html; charset=utf-8");
     $page = 7600;
     $isend = false;
     while (true) {
         if ($isend) {
             break;
         }
         ob_end_flush();
         echo $page . "<br/>";
         flush();
         $listurl = "http://wenda.haosou.com/chip/entanslist?pn=" . $page . "%0A&qid=1433735543";
         $page++;
         $pagecontent = \phpQuery::newDocumentFile($listurl);
         $results = pq('li a')->find();
         if (empty($results)) {
             continue;
         }
         foreach ($results as $result) {
             $url = pq($result)->attr('href');
             $url = "http://wenda.haosou.com" . $url;
             $iscollect = D('ClCollect')->findUrl($url);
             if ($iscollect) {
                 continue;
             }
             $content = \phpQuery::newDocumentFile($url);
             $title = pq('.js-ask-title')->text();
             if (empty($title)) {
                 continue;
             }
             $answer = pq('.resolved-cnt')->text();
             $data['question_title'] = $title;
             $data['question_detail'] = $title;
             $data['published_uid'] = 0;
             $data['game_id'] = 7;
             $data['anonymous'] = 1;
             $data['is_recommend'] = 1;
             $Question = D('AsQuestion');
             $question_id = $Question->addQuestion($data);
             if ($question_id) {
                 $answer = trim($answer, "\r\n\t");
                 $adata['question_id'] = $question_id;
                 $adata['answer_content'] = $answer;
                 $adata['anonymous'] = 1;
                 $answer_id = D('AsAnswer')->addAnswer($adata);
                 D('AsQuestion')->saveCollectAnswer($question_id, $answer_id);
                 $this->sendToBaidu($question_id);
             }
             $cdata['url'] = $url;
             $cdata['site'] = "360";
             D('ClCollect')->addCollect($cdata);
         }
     }
     return;
 }
开发者ID:nullog,项目名称:zhanglubao,代码行数:58,代码来源:QuestionController.class.php

示例3: search404

function search404($url)
{
    phpQuery::newDocumentFile($url);
    $a_arr = pq("a");
    $a_count = count($a_arr);
    for ($i = 0; $i < $a_count; $i++) {
        $url_arr[] = pq("a:eq({$i})")->attr("href");
    }
    return $url_arr;
}
开发者ID:benhuang1024,项目名称:phpTool,代码行数:10,代码来源:index.php

示例4: actionIndex

 public function actionIndex()
 {
     $url = 'http://android.myapp.com/myapp/detail.htm?apkName=me.thinknext.shufa';
     phpQuery::newDocumentFile($url);
     $div = pq(".det-ins-num")->html();
     $downloads = str_replace('下载', '', $div);
     if (preg_match("/^([1-9][0-9]*)\$/", $downloads) == true) {
         $ctime = date('Y-m-d H:i:s');
         $sql = "insert into moyu_downloads(downloads,ctime) VALUES(" . $downloads . ",'" . $ctime . "')";
         $command = Yii::app()->db->createCommand($sql);
         $command->execute();
     }
 }
开发者ID:qyt1988528,项目名称:tongji,代码行数:13,代码来源:MoyuDownloadsCommand.php

示例5: run

function run($page)
{
    $destination = "http://www.ttpet.com/zixun/42/category-catid-42-{$page}.html";
    echo 'Crawling ' . $destination . "\n";
    phpQuery::newDocumentFile($destination);
    $articles = pq('#main_bg .zixunmain .p_lf .p_pad')->find('ul');
    foreach ($articles as $article) {
        $m['title'] = pq($article)->find('dl dd a')->html();
        $final[] = $m;
    }
    echo '=========== Page ===========> ' . $page . "\r\n";
    print_r($final);
}
开发者ID:jackton,项目名称:YOF,代码行数:13,代码来源:pcntl.php

示例6: get_list

function get_list($url)
{
    $result = array();
    $result["data"] = array();
    $html = phpQuery::newDocumentFile($url);
    $lists = $html['ul.rstlist-info li .rstname-wrap strong'];
    foreach ($lists as $list) {
        $url = pq($list)->find('a')->attr('href');
        $text = pq($list)->find('a')->text();
        $result['data'][] = array("url" => $url, "name" => $text);
    }
    $next_url = $html['.next']->attr("href");
    $result['paging'] = array("next" => $next_url);
    return $result;
}
开发者ID:rysk92,项目名称:ramenlog,代码行数:15,代码来源:get.php

示例7: _getIdsByUrl

 /**
  * 根据url获取skus
  * @param  string $url
  * @return array      
  */
 private function _getIdsByUrl($url)
 {
     $ids = [];
     phpQuery::newDocumentFile($url);
     $a = pq('#plist .gl-item div[data-sku]');
     foreach ($a as $value) {
         $sku = pq($value)->attr('data-sku');
         if (strlen($sku) <= 7) {
             array_push($ids, trim($sku));
         }
         if (count($ids) >= $this->count) {
             break;
         }
     }
     return $ids;
 }
开发者ID:limi58,项目名称:fetchJD,代码行数:21,代码来源:Trends.php

示例8: getCategories

 public function getCategories($url, $excludes = [])
 {
     $categories = [];
     phpQuery::newDocumentFile($url);
     $title = pq('#J_selector [clstag="thirdtype|keycount|thirdtype|select"] b')->text();
     $itemDOM = pq('#J_selector .sl-wrap');
     foreach ($itemDOM as $value) {
         $key = trim(str_replace(':', '', pq($value)->find('.sl-key span')->text()));
         if (in_array($key, $excludes)) {
             continue;
         }
         if ($key !== '品牌') {
             $names = $this->getNames($value, 100);
         } else {
             $names = $this->getNames($value, 24);
         }
         array_push($categories, ['key' => $key, 'values' => $names]);
     }
     // dump($categories);
     return $categories;
 }
开发者ID:limi58,项目名称:fetchJD,代码行数:21,代码来源:Categories.php

示例9: pq

$p->dump();
print "\n";
$testName = 'WrapAll';
$testResult = 1;
phpQuery::newDocumentFile('test.html')->find('p')->slice(1, 3)->wrapAll('<div class="wrapper">');
$result = pq('.wrapper');
if ($result->size() == $testResult) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
$result->dump();
print "\n";
$testName = 'WrapInner';
$testResult = 3;
phpQuery::newDocumentFile('test.html')->find('li:first')->wrapInner('<div class="wrapper">');
$result = pq('.wrapper p');
if ($result->size() == $testResult) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
print $result->dump();
print "\n";
// TODO !
$testName = 'WrapAllTest';
/*
$doc = phpQuery::newDocumentHTML('<div id="myDiv"></div>');
$doc['#myDiv']->append('hors paragraphe<p>Test</p>hors paragraphe')
	->contents()
		->not('[nodeType=1]')
开发者ID:mrofi,项目名称:database-wilayah-indonesia,代码行数:31,代码来源:test_wrap.php

示例10: get_Author

function get_Author($url)
{
    $productPage = phpQuery::newDocumentFile($url);
    return trim(str_replace('(Author)', '', text_prepare(pq($productPage)->find('#byline .author .a-popover-preload .a-size-medium')->text())));
}
开发者ID:ethanclevenger91,项目名称:amazon-wish-lister,代码行数:5,代码来源:wishlist.php

示例11: a789fhasdui3124

//));
//function v87shs79d8fhs9d($html) {
//	$title = phpQuery::newDocument($html)->find('title');
//	$testName = 'Simple AJAX';
//	if ( strpos(strtolower($title->html()), 'wikipedia') !== false )
//		print "Test '$testName' PASSED :)";
//	else {
//		print "Test '$testName' <strong>FAILED</strong> !!! ";
//		print "<pre>";
//		print_r($title->whois());
//		print "</pre>\n";
//	}
//	print "\n";
//}
$testName = 'Load';
$test = phpQuery::newDocumentFile('test.html')->find('div:first')->load('http://wikipedia.org/ div[lang]');
if (pq('div[lang]')->size()) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
    print "<pre>";
    print "</pre>\n";
}
print "\n";
// http://code.google.com/p/phpquery/issues/detail?id=130
$pq = phpQuery::ajax(array('url' => 'http://' . $_SERVER['SERVER_NAME'] . preg_replace('@/[^/]+$@', '/test_ajax_data_1', $_SERVER['REQUEST_URI']), 'success' => 'a789fhasdui3124', 'error' => 'jhdbg786213u8dsfg7y'));
function a789fhasdui3124($html)
{
    $testName = 'AJAX request text node';
    if ($html == 'hello world') {
        print "Test '{$testName}' PASSED :)";
开发者ID:limi58,项目名称:fetchJD,代码行数:31,代码来源:test_ajax.php

示例12: print_r

}
print_r($result->whois());
print "\n";
$testName = 'Filter with multiplie selectors';
$testResult = array('p.body');
$testDOM = phpQuery::newDocumentFile('test.html');
$single = $testDOM->find('p')->filter('.body')->add($testDOM->find('p')->filter('.title'));
$double = $testDOM->find('p')->filter('.body, .title');
if ($single->length == count($double)) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
print "\n";
print_r($single->whois());
print "\n";
print_r($double->whois());
print "\n";
$testName = 'Attributes in HTML element';
$validResult = 'testValue';
$result = phpQuery::newDocumentFile('test.html')->find('html')->empty()->attr('test', $validResult);
$result = phpQuery::newDocument($result->htmlOuter())->find('html')->attr('test');
//similar_text($result->htmlOuter(), $validResult, $similarity);
if ($result == $validResult) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
    print "<pre>";
    print $result;
    print "</pre>\n";
}
开发者ID:atofighi,项目名称:phpquery,代码行数:31,代码来源:test_2.php

示例13: pq

<?php

require_once '../phpQuery/phpQuery.php';
phpQuery::$debug = true;
$testName = 'ReplaceWith';
phpQuery::newDocumentFile('test.html')->find('p:eq(1)')->replaceWith("<p class='newTitle'>\n                        this is example title\n                    </p>");
$result = pq('p:eq(1)');
if ($result->hasClass('newTitle')) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
$result->dump();
print "\n";
$testName = 'ReplaceAll';
$testResult = 3;
phpQuery::newDocumentFile('test.html');
pq('<div class="replacer">')->replaceAll('li:first p');
$result = pq('.replacer');
if ($result->size() == $testResult) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
$result->dump();
print "\n";
开发者ID:atofighi,项目名称:phpquery,代码行数:26,代码来源:test_replace.php

示例14: foreach

print "\n";
// CLONE
$testName = 'Clone';
$testResult = 3;
$document;
$p = phpQuery::newDocumentFile('test.html')->toReference($document)->find('p:first');
foreach (array(0, 1, 2) as $i) {
    $p->clone()->addClass("clone-test")->addClass("class-{$i}")->insertBefore($p);
}
if (pq('.clone-test')->size() == $testResult) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
print "\n";
// SIBLINGS
$testName = 'Next';
$testResult = 3;
$document;
$result = phpQuery::newDocumentFile('test.html')->find('li:first')->next()->next()->prev()->is('#testID');
if ($result) {
    print "Test '{$testName}' PASSED :)";
} else {
    print "Test '{$testName}' <strong>FAILED</strong> !!! ";
}
print "\n";
?>


<?php 
die;
开发者ID:fobiaphp,项目名称:phpquery,代码行数:31,代码来源:test_4.php

示例15: error_reporting

error_reporting(0);
header("Content-Type: text/html;charset=utf-8");
if (!isset($_GET['word'])) {
    header('Location: /');
} elseif ($_GET['word'] == '') {
    header('Location: /');
} else {
    $word = $_GET['word'];
}
if (isset($_GET['page'])) {
    $page = $_GET['page'];
} else {
    $page = 1;
}
include './includes/phpQuery.php';
phpQuery::newDocumentFile(get_base() . 'fetch.php?word=' . urlencode($word) . '&page=' . $page);
$list = pq('.g');
foreach ($list as $li) {
    $data['name'][] = pq($li)->find('.r')->find('a')->html();
    $data['_url'][] = pq($li)->find('.r')->find('a')->attr('href');
    $data['desc'][] = pq($li)->find('.s')->find('.st')->html();
}
$data['num'][0] = pq('#resultStats')->html();
$data['num'][1] = get_number($data['num'][0]);
foreach ($data['_url'] as $key => $value) {
    $data['url'][] = get_true_url($data['_url'][$key]);
}
foreach ($data['url'] as $key => $value) {
    if (substr($value, 0, 1) == '/') {
        unset($data['url'][$key], $data['name'][$key], $data['desc'][$key]);
    }
开发者ID:changlor,项目名称:MoeSearch,代码行数:31,代码来源:search.php


注:本文中的phpQuery::newDocumentFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。