本文整理汇总了PHP中phpQuery::debug方法的典型用法代码示例。如果您正苦于以下问题:PHP phpQuery::debug方法的具体用法?PHP phpQuery::debug怎么用?PHP phpQuery::debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpQuery
的用法示例。
在下文中一共展示了phpQuery::debug方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: script
/**
* Enter description here...
*
* @param phpQueryObject $self
*/
public static function script($self, $arg1)
{
$params = func_get_args();
$params = array_slice($params, 2);
$return = null;
$config = self::$config;
if (phpQueryPlugin_Scripts::$scriptMethods[$arg1]) {
phpQuery::callbackRun(phpQueryPlugin_Scripts::$scriptMethods[$arg1], array($self, $params, &$return, $config));
} elseif ($arg1 != '__config' && file_exists(dirname(__FILE__) . "/Scripts/{$arg1}.php")) {
phpQuery::debug("Loading script '{$arg1}'");
require dirname(__FILE__) . "/Scripts/{$arg1}.php";
} else {
phpQuery::debug("Requested script '{$arg1}' doesn't exist");
}
return $return ? $return : $self;
}
示例2: 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";
示例3: add
/**
* Binds a handler to one or more events (like click) for each matched element.
* Can also bind custom events.
*
* @param DOMNode|phpQueryObject|string $document
* @param unknown_type $type
* @param unknown_type $data Optional
* @param unknown_type $callback
*
* @TODO support '!' (exclusive) events
* @TODO support more than event in $type (space-separated)
* @TODO support binding to global events
*/
public static function add($document, $node, $type, $data, $callback = null)
{
phpQuery::debug("Binding '{$type}' event");
$documentID = phpQuery::getDocumentID($document);
// if (is_null($callback) && is_callable($data)) {
// $callback = $data;
// $data = null;
// }
$eventNode = self::getNode($documentID, $node);
if (!$eventNode) {
$eventNode = self::setNode($documentID, $node);
}
if (!isset($eventNode->eventHandlers[$type])) {
$eventNode->eventHandlers[$type] = array();
}
$eventNode->eventHandlers[$type][] = array('callback' => $callback, 'data' => $data);
}
示例4: debug
public static function debug($text)
{
phpQuery::debug($text);
}
示例5: dumpTree
public function dumpTree($html = true, $title = true)
{
$output = $title ? 'DUMP #' . phpQuery::$dumpCount++ . " \n" : '';
$debug = phpQuery::$debug;
phpQuery::$debug = false;
foreach ($this->stack() as $node) {
$output .= $this->__dumpTree($node);
}
phpQuery::$debug = $debug;
print $html ? nl2br(str_replace(' ', ' ', $output)) : $output;
return $this;
}
示例6: array
*/
class phpQuery
{
static $defaultDocumentID;
static $debug = 0;
static $documents = array();
static $defaultCharset = 'utf-8';
static function debug($text)
{
if (self::$debug) {
print var_dump($text);
}
}
}
require_once '../src/phpQuery/DOMDocumentWrapper.php';
phpQuery::$debug = 2;
/* ENCODINGS */
//print '<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-2">';
print '<meta http-equiv="Content-Type" content="text/html;charset=utf-8">';
/* HTML */
//$htmlIso = new DOMDocumentWrapper(
// file_get_contents('document-types/document-iso88592.html')
//);
//$htmlIsoNoCharset = new DOMDocumentWrapper(
// file_get_contents('document-types/document-iso88592-nocharset.html'),
// 'text/html;charset=iso-8859-2'
//);
$htmlUtf = new phpQuery\DOMDocumentWrapper(file_get_contents('document-types/document-utf8.html'));
var_dump($htmlUtf->markup());
//$htmlUtfNoCharset = new DOMDocumentWrapper(
// file_get_contents('document-types/document-utf8-nocharset.html'),
示例7: browserReceive
/**
* @param Zend_Http_Client $xhr
*/
public static function browserReceive($xhr)
{
phpQuery::debug("[WebBrowser] Received from " . $xhr->getUri(true));
// TODO handle meta redirects
$body = $xhr->getLastResponse()->getBody();
// XXX error ???
if (strpos($body, '<!doctype html>') !== false) {
$body = '<html>' . str_replace('<!doctype html>', '', $body) . '</html>';
}
$pq = phpQuery::newDocument($body);
$pq->document->xhr = $xhr;
$pq->document->location = $xhr->getUri(true);
$refresh = $pq->find('meta[http-equiv=refresh]')->add('meta[http-equiv=Refresh]');
if ($refresh->size()) {
// print htmlspecialchars(var_export($xhr->getCookieJar()->getAllCookies(), true));
// print htmlspecialchars(var_export($xhr->getLastResponse()->getHeader('Set-Cookie'), true));
phpQuery::debug("Meta redirect... '{$refresh->attr('content')}'\n");
// there is a refresh, so get the new url
$content = $refresh->attr('content');
$urlRefresh = substr($content, strpos($content, '=') + 1);
$urlRefresh = trim($urlRefresh, '\'"');
// XXX not secure ?!
phpQuery::ajaxAllowURL($urlRefresh);
// $urlRefresh = urldecode($urlRefresh);
// make ajax call, passing last $xhr object to preserve important stuff
$xhr = phpQuery::ajax(array('type' => 'GET', 'url' => $urlRefresh, 'dataType' => 'html'), $xhr);
if ($xhr->getLastResponse()->isSuccessful()) {
// if all is ok, repeat this method...
return call_user_func_array(array('phpQueryPlugin_WebBrowser', 'browserReceive'), array($xhr));
}
} else {
return $pq;
}
}
示例8: match
public static function match($html, $data, $rule)
{
$match_hash = array();
if ($data['dom']) {
iPHP::import(iPHP_LIB . '/phpQuery.php');
spider::$dataTest && $_GET['pq_debug'] && (phpQuery::$debug = 1);
$doc = phpQuery::newDocumentHTML($html, 'UTF-8');
if (strpos($data['rule'], '@') !== false) {
list($content_dom, $content_attr) = explode("@", $data['rule']);
$content_fun = 'attr';
} else {
list($content_dom, $content_fun, $content_attr) = explode("\n", $data['rule']);
}
$content_dom = trim($content_dom);
$content_fun = trim($content_fun);
$content_attr = trim($content_attr);
$content_fun or $content_fun = 'html';
if ($data['multi']) {
$conArray = array();
$_content = null;
foreach ($doc[$content_dom] as $doc_key => $doc_value) {
if ($content_attr) {
$_content = phpQuery::pq($doc_value)->{$content_fun}($content_attr);
} else {
$_content = phpQuery::pq($doc_value)->{$content_fun}();
}
$cmd5 = md5($_content);
if ($match_hash[$cmd5]) {
break;
}
$conArray[$doc_key] = $_content;
$match_hash[$cmd5] = true;
}
if (spider::$dataTest) {
echo "<b>多条匹配结果:</b><pre>";
print_r($match_hash);
echo "</pre><hr />";
}
$content = implode('#--iCMS.PageBreak--#', $conArray);
unset($conArray, $_content, $match_hash);
} else {
if ($content_attr) {
$content = $doc[$content_dom]->{$content_fun}($content_attr);
} else {
$content = $doc[$content_dom]->{$content_fun}();
}
}
phpQuery::unloadDocuments($doc->getDocumentID());
unset($doc);
} else {
if (trim($data['rule']) == '<%content%>') {
$content = $html;
} else {
$data_rule = spiderTools::pregTag($data['rule']);
if (preg_match('/(<\\w+>|\\.\\*|\\.\\+|\\\\d|\\\\w)/i', $data_rule)) {
if ($data['multi']) {
preg_match_all('|' . $data_rule . '|is', $html, $matches, PREG_SET_ORDER);
$conArray = array();
foreach ((array) $matches as $mkey => $mat) {
$cmd5 = md5($mat['content']);
if ($match_hash[$cmd5]) {
break;
}
$conArray[$mkey] = $mat['content'];
$match_hash[$cmd5] = true;
}
if (spider::$dataTest) {
echo "<b>多条匹配结果:</b><pre>";
print_r($match_hash);
echo "</pre><hr />";
}
$content = implode('#--iCMS.PageBreak--#', $conArray);
unset($conArray, $match_hash);
} else {
preg_match('|' . $data_rule . '|is', $html, $matches, $PREG_SET_ORDER);
$content = $matches['content'];
}
} else {
$content = $data_rule;
}
}
}
return $content;
}
示例9: browserDownload
/**
* @param Zend_Http_Client $xhr
*/
public static function browserDownload($xhr)
{
phpQuery::debug("[WebBrowser] Received from " . $xhr->getUri(true));
// TODO handle meta redirects
$body = $xhr->getLastResponse()->getBody();
return $body;
}
示例10: browser
/**
*
* @param $ajaxSettings
* @param $callback
* @param $param1
* @param $param2
* @param $param3
* @return phpQueryObject
*/
public static function browser($ajaxSettings, $callback, $param1 = null, $param2 = null, $param3 = null)
{
if (self::plugin('WebBrowser')) {
$params = func_get_args();
return self::callbackRun(array(self::$plugins, 'browser'), $params);
} else {
phpQuery::debug('WebBrowser plugin not available...');
}
}
示例11: content
//.........这里部分代码省略.........
$this->content_right_code = trim($rule['page_url_right']);
$this->content_error_code = trim($rule['page_url_error']);
$this->curl_proxy = $rule['proxy'];
$pcontent = '';
$pcon = '';
foreach ($page_url_array as $pukey => $purl) {
//usleep(100);
$phtml = $this->remote($purl);
if (empty($phtml)) {
break;
}
$phttp = $this->check_content_code($phtml);
if ($phttp['match'] == false) {
break;
}
$pageurl[] = $purl;
$pcon .= $phttp['content'];
}
gc_collect_cycles();
$html .= $pcon;
unset($pcon);
$this->allHtml = $html;
if ($this->contTest) {
echo "<pre>";
print_r($pageurl);
echo "</pre><hr />";
}
} else {
$html = $this->allHtml;
}
}
if ($data['dom']) {
iPHP::import(iPHP_LIB . '/phpQuery.php');
$this->contTest && $_GET['pq_debug'] && (phpQuery::$debug = 1);
$doc = phpQuery::newDocumentHTML($html, 'UTF-8');
//echo "\ndata:getDocumentID:".$doc->getDocumentID()."\n";
list($content_dom, $content_fun, $content_attr) = explode("\n", $data['rule']);
$content_dom = trim($content_dom);
$content_fun = trim($content_fun);
$content_attr = trim($content_attr);
$content_fun or $content_fun = 'html';
if ($data['multi']) {
$conArray = array();
foreach ($doc[$content_dom] as $doc_key => $doc_value) {
if ($content_attr) {
$conArray[] = phpQuery::pq($doc_value)->{$content_fun}($content_attr);
} else {
$conArray[] = phpQuery::pq($doc_value)->{$content_fun}();
}
}
$content = implode('#--iCMS.PageBreak--#', $conArray);
unset($conArray);
} else {
if ($content_attr) {
$content = $doc[$content_dom]->{$content_fun}($content_attr);
} else {
$content = $doc[$content_dom]->{$content_fun}();
}
}
if ($this->contTest) {
print_r(htmlspecialchars($content));
echo "<hr />";
}
phpQuery::unloadDocuments($doc->getDocumentID());
unset($doc);
} else {
示例12: crawl
public static function crawl($work = NULL, $pid = NULL, $_rid = NULL, $_urls = null, $callback = null)
{
$pid === NULL && ($pid = spider::$pid);
if ($pid) {
$project = spider::project($pid);
$cid = $project['cid'];
$rid = $project['rid'];
$prule_list_url = $project['list_url'];
$lastupdate = $project['lastupdate'];
} else {
$cid = spider::$cid;
$rid = spider::$rid;
}
if (empty($rid) && $_rid !== NULL) {
$rid = $_rid;
}
if ($work == 'shell') {
$lastupdate = $project['lastupdate'];
if ($project['psleep']) {
if (time() - $lastupdate < $project['psleep']) {
echo '采集方案[' . $pid . "]:" . format_date($lastupdate) . "刚采集过了,请" . $project['psleep'] / 3600 . "小时后在继续采集\n";
return;
}
}
echo "[32m开始采集方案[" . $pid . "] 采集规则[" . $rid . "][0m\n";
}
$ruleA = spider::rule($rid);
$rule = $ruleA['rule'];
$urls = $rule['list_urls'];
$project['urls'] && ($urls = $project['urls']);
spiderUrls::$urls && ($urls = spiderUrls::$urls);
$_urls && ($urls = $_urls);
$urlsArray = explode("\n", $urls);
$urlsArray = array_filter($urlsArray);
$_urlsArray = $urlsArray;
$urlsList = array();
if ($work == 'shell') {
// echo "$urls\n";
print_r($urlsArray);
}
foreach ($_urlsArray as $_key => $_url) {
$_url = htmlspecialchars_decode($_url);
$_urlsList = array();
/**
* RULE@rid@url
* url使用[rid]规则采集并返回列表结果
*/
if (strpos($_url, 'RULE@') !== false) {
list($___s, $_rid, $_urls) = explode('@', $_url);
if (spider::$ruleTest) {
print_r('<b>使用[rid:' . $_rid . ']规则抓取列表</b>:' . $_urls);
echo "<hr />";
}
$_urlsList = spiderUrls::crawl($work, false, $_rid, $_urls, 'CALLBACK@URL');
$urlsList = array_merge($urlsList, $_urlsList);
unset($urlsArray[$_key]);
} else {
preg_match('|.*<(.*)>.*|is', $_url, $_matches);
if ($_matches) {
list($format, $begin, $num, $step, $zeroize, $reverse) = explode(',', $_matches[1]);
$url = str_replace($_matches[1], '*', trim($_matches[0]));
$_urlsList = spiderTools::mkurls($url, $format, $begin, $num, $step, $zeroize, $reverse);
unset($urlsArray[$_key]);
$urlsList = array_merge($urlsList, $_urlsList);
}
}
}
$urlsList && ($urlsArray = array_merge($urlsArray, $urlsList));
unset($_urlsArray, $_key, $_url, $_matches, $_urlsList, $urlsList);
$urlsArray = array_unique($urlsArray);
// spider::$useragent = $rule['user_agent'];
// spider::$encoding = $rule['curl']['encoding'];
// spider::$referer = $rule['curl']['referer'];
// spider::$charset = $rule['charset'];
if (empty($urlsArray)) {
if ($work == 'shell') {
echo "采集列表为空!请填写!\n";
return false;
}
iPHP::alert('采集列表为空!请填写!', 'js:parent.window.iCMS_MODAL.destroy();');
}
// if(spider::$ruleTest){
// echo "<pre>";
// print_r(iS::escapeStr($project));
// print_r(iS::escapeStr($rule));
// echo "</pre>";
// echo "<hr />";
// }
if ($rule['mode'] == "2") {
iPHP::import(iPHP_LIB . '/phpQuery.php');
spider::$ruleTest && $_GET['pq_debug'] && (phpQuery::$debug = 1);
}
$pubArray = array();
$pubCount = array();
$pubAllCount = array();
spider::$curl_proxy = $rule['proxy'];
spider::$urlslast = null;
foreach ($urlsArray as $key => $url) {
$url = trim($url);
spider::$urlslast = $url;
//.........这里部分代码省略.........
示例13: dumpTree
public function dumpTree()
{
print 'DUMP #' . phpQuery::$dumpCount++ . ' ';
$debug = phpQuery::$debug;
phpQuery::$debug = false;
foreach ($this->stack() as $node) {
print $this->__dumpTree($node);
}
phpQuery::$debug = $debug;
return $this;
}