本文整理汇总了PHP中pq函数的典型用法代码示例。如果您正苦于以下问题:PHP pq函数的具体用法?PHP pq怎么用?PHP pq使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pq函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: readCoinInformation
protected function readCoinInformation($pq_tr)
{
$coin_data = array();
$img_indexes = array('obverse', 'reverse');
$pq_td = $pq_tr->find('td');
$as = $pq_td->find('a');
foreach ($as as $index => $a) {
$pq_a = pq($a);
switch ($index) {
case 0:
case 1:
$img_url = $this->fixImageUrl($pq_a->find('img')->attr('src'));
$coin_data[$img_indexes[$index]] = $img_url;
break;
case 2:
$coin_data['name'] = $pq_a->text();
$pq_td->find('span, a, br')->remove();
$chr = chr(194) . chr(160);
$km = trim(str_replace($chr, ' ', $pq_td->text()));
$km = trim(str_replace('Total:', '', $km));
$coin_data['km'] = $km;
break;
}
}
return $coin_data;
}
开发者ID:Qmegas,项目名称:numista-api,代码行数:26,代码来源:usercollection.php
示例2: run
public function run()
{
$content = ob_get_clean();
$formatted = phpQuery::newDocument($content);
$imageNodes = pq('img');
foreach ($imageNodes as $imNode) {
$imNode = pq($imNode);
$imPath = $imNode->attr('src');
$thumbPath = $this->thumbsDir . '/' . basename($imPath);
//$thumbPath = dirname($imPath).'/thumbs/'.basename($imPath);
// Create thumbnail if not exists
if (!file_exists($thumbPath)) {
$imgObj = Yii::app()->simpleImage->load($imPath);
if (!isset($this->thumbHeight)) {
$imgObj->resizeToWidth($this->thumbWidth);
} else {
$imgObj->resize($this->thumbWidth, $this->thumbHeight);
}
$imgObj->save($thumbPath);
}
$imNode->wrap('<a href="' . $imPath . '" rel="gallery"></a>');
$imNode->attr('src', Yii::app()->request->baseUrl . DIRECTORY_SEPARATOR . $thumbPath);
}
echo $formatted;
}
开发者ID:hipogea,项目名称:zega,代码行数:25,代码来源:Thumbnailer.php
示例3: hyphenate
public static function hyphenate($strBuffer)
{
global $objPage;
$arrSkipPages = \Config::get('hyphenator_skipPages');
if (is_array($arrSkipPages) && in_array($objPage->id, $arrSkipPages)) {
return $strBuffer;
}
$o = new \Org\Heigl\Hyphenator\Options();
$o->setHyphen(\Config::get('hyphenator_hyphen'))->setDefaultLocale(static::getLocaleFromLanguage($objPage->language))->setRightMin(\Config::get('hyphenator_rightMin'))->setLeftMin(\Config::get('hyphenator_leftMin'))->setWordMin(\Config::get('hyphenator_wordMin'))->setFilters(\Config::get('hyphenator_filter'))->setQuality(\Config::get('hyphenator_quality'))->setTokenizers(\Config::get('hyphenator_tokenizers'));
$h = new \Org\Heigl\Hyphenator\Hyphenator();
$h->setOptions($o);
$doc = \phpQuery::newDocumentHTML($strBuffer);
foreach (pq('body')->find(\Config::get('hyphenator_tags')) as $n => $item) {
$strText = pq($item)->html();
// ignore html tags, otherwise ­ will be added to links for example
if ($strText != strip_tags($strText)) {
continue;
}
$strText = str_replace('­', '', $strText);
// remove manual ­ html entities before
$strText = $h->hyphenate($strText);
if (is_array($strText)) {
$strText = current($strText);
}
pq($item)->html($strText);
}
return $doc->htmlOuter();
}
开发者ID:heimrichhannot,项目名称:contao-hyphenator,代码行数:28,代码来源:Hyphenator.php
示例4: getHorario
function getHorario() {
if($this->horario != null) return $this->horario;
parent::process();
$dotw = array('Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado');
$this->horario = array('Lunes' => array()
, 'Martes' => array()
, 'Miércoles' => array()
, 'Jueves' => array()
, 'Viernes' => array()
, 'Sábado' => array());
foreach(pq('td.dia') as $day => $bloques) {
foreach(pq('div', $bloques) as $tmp_bloque) {
$bloque = new stdClass();
$bloque->codigo = pq('a', $tmp_bloque)->html();
list(,$tmp_tipo,, $tmp_horario) = pq($tmp_bloque)->contents()->elements;
$bloque->tipo = trim(pq($tmp_tipo)->text());
list($bloque->sala, $bloque->hora) = explode(chr(194).chr(160), pq($tmp_horario)->text());
$this->horario[$dotw[$day]][] = $bloque;
}
}
return $this->horario;
}
开发者ID:rduenasf,项目名称:ucursos-scrapper,代码行数:26,代码来源:ucursos.horario.scrapper.php
示例5: get_data
public function get_data()
{
if (!class_exists('phpQuery')) {
include dirname(__FILE__) . '/phpQuery.php';
}
$response = wp_remote_get($this->url . '/tags');
if (is_wp_error($response)) {
return false;
}
phpQuery::newDocument($response['body']);
$version = false;
$zip_url = false;
foreach (pq('table.tags a.name') as $tag) {
$tag = pq($tag);
if (version_compare($tag->text(), $version, '>=')) {
$href = $tag->attr('href');
$commit = substr($href, strrpos($href, '/') + 1);
$zip_url = $this->url . '/snapshot/' . $commit . '.zip';
$version = $tag->text();
$updated_at = $tag->parent()->prev()->text();
}
}
$this->new_version = $version;
$this->zip_url = $zip_url;
$this->updated_at = date('Y-m-d', strtotime($updated_at));
$this->description = pq('div.page_footer_text')->text();
}
开发者ID:webbab,项目名称:github-plugin-search,代码行数:27,代码来源:gitweb.php
示例6: success
public function success($response)
{
$pq = phpQuery::newDocument($response);
foreach ($this->calls as $k => $r) {
// check if method exists
if (!method_exists(get_class($pq), $r['method'])) {
throw new Exception("Method '{$r['method']}' not implemented in phpQuery, sorry...");
// execute method
} else {
$pq = call_user_func_array(array($pq, $r['method']), $r['arguments']);
}
}
if (!isset($this->options['dataType'])) {
$this->options['dataType'] = '';
}
switch (strtolower($this->options['dataType'])) {
case 'json':
if ($pq instanceof PHPQUERYOBJECT) {
$results = array();
foreach ($pq as $node) {
$results[] = pq($node)->htmlOuter();
}
print phpQuery::toJSON($results);
} else {
print phpQuery::toJSON($pq);
}
break;
default:
print $pq;
}
// output results
}
开发者ID:AloneFallen,项目名称:phpquery,代码行数:32,代码来源:jQueryServer.php
示例7: getList
protected function getList()
{
$this->data['list'] = array();
$ul = $this->q->find('#liste_echanges li');
if ($ul->count() == 0) {
return;
}
$years = $ul->find('ul li');
foreach ($years as $year) {
$pq_year = pq($year);
$html = trim($pq_year->html());
$year_txt = html_entity_decode(trim(strip_tags(substr($html, 0, strpos($html, ':')))));
$item = array('year' => $year_txt, 'users' => array());
$as = $pq_year->find('a');
foreach ($as as $a) {
$pq_a = pq($a);
$href = $pq_a->attr('href');
$user_name = $pq_a->text();
$ret = preg_match('|membre\\.php\\?id=([0-9]+)|', $href, $matches);
if ($ret == 1 && isset($matches[1])) {
$item['users'][] = array('id' => $matches[1], 'name' => $user_name);
}
}
$this->data['list'][] = $item;
}
}
开发者ID:Qmegas,项目名称:numista-api,代码行数:26,代码来源:coinexchange.php
示例8: getNovedades
function getNovedades() {
if($this->novedades != null) return $this->novedades;
parent::process();
$this->novedades = array();
foreach(pq('div.blog') as $item) {
$novedad = new stdClass();
$tmp_autor = pq('em', $item);
$tmp_autor_i = strpos($tmp_autor, '<a class');
$tmp_autor_f = strpos($tmp_autor, '</a>') + 4;
$novedad->texto = pq($item)->children('p');
foreach(pq('a', $novedad->texto) as $href) {
$href_url = pq($href)->attr('href');
if(substr($href_url, 0, 2) == 'r/')
pq($href)->attr('href', $this->url . $href_url);
}
foreach(pq('img', $novedad->texto) as $href) {
$img_src = pq($href)->attr('src');
if(substr($img_src, 0, 2) == 'r/')
pq($href)->attr('src', $this->url . $img_src);
}
$novedad->texto = mb_convert_encoding(pq($novedad->texto)->html(), 'UTF-8');
$novedad->titulo = trim(pq(pq($item)->children('h1'))->text());
$novedad->fecha = trim(substr($tmp_autor, $tmp_autor_f));
$novedad->autor = new stdClass();
$novedad->autor->nombre = pq(substr($tmp_autor, $tmp_autor_i, $tmp_autor_f - $tmp_autor_i + 1))->html();
$novedad->autor->avatar = pq('img')->attr('src');
$this->novedades[] = $novedad;
}
return $this->novedades;
}
开发者ID:rduenasf,项目名称:ucursos-scrapper,代码行数:33,代码来源:ucursos.novedades.scrapper.php
示例9: elseif
public function &__get($key)
{
if (isset($this->data[$key])) {
return $this->data[$key];
} elseif (isset($this->data['organization'][$key])) {
return $this->data['organization'][$key];
} elseif (method_exists($this, '_load_' . $key)) {
$func = '_load_' . $key;
return $this->{$func}();
} elseif (isset($this->form_object)) {
switch ($key) {
case 'organization':
$this->data['organization']['id'] = pq('id')->text();
$this->data['organization']['short_name'] = pq('short_name')->text();
return $this->data['organization'];
case 'id':
$this->data['organization']['id'] = pq('id')->text();
return $this->data['organization']['id'];
case 'short_name':
$this->data['organization']['short_name'] = pq('short_name')->text();
return $this->data['organization']['short_name'];
default:
$this->data[$key] = pq($key)->text();
return $this->data[$key];
}
//end switch
}
//end elseif
return null;
}
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:30,代码来源:Form.php
示例10: getLinkContent
public function getLinkContent()
{
require_once './ThinkPHP/Library/Vendor/Collection/phpQuery.php';
$link = op_t(I('post.url'));
$content = get_content_by_url($link);
$charset = preg_match("/<meta.+?charset=[^\\w]?([-\\w]+)/i", $content, $temp) ? strtolower($temp[1]) : "utf-8";
\phpQuery::$defaultCharset = $charset;
\phpQuery::newDocument($content);
$title = pq("meta[name='title']")->attr('content');
if (empty($title)) {
$title = pq("title")->html();
}
$title = iconv($charset, "UTF-8", $title);
$keywords = pq("meta[name='keywords'],meta[name='Keywords']")->attr('content');
$description = pq("meta[name='description'],meta[name='Description']")->attr('content');
$url = parse_url($link);
$img = pq("img")->eq(0)->attr('src');
if (is_bool(strpos($img, 'http://'))) {
$img = 'http://' . $url['host'] . $img;
}
$title = text($title);
$description = text($description);
$keywords = text($keywords);
$return['title'] = $title;
$return['img'] = $img;
$return['description'] = empty($description) ? $title : $description;
$return['keywords'] = empty($keywords) ? $title : $keywords;
exit(json_encode($return));
}
开发者ID:ccccy,项目名称:wuanlife,代码行数:29,代码来源:LinkController.class.php
示例11: Process
/**
* Process emoticons inside a string
* @since Version 3.10.0
* @param string|DOMDocument $string The HTML or text block to process
* @param boolean $doEmoticons Boolean flag for processing or skipping emoticons
* @return DOMDocument
*/
public static function Process($string, $doEmoticons = true)
{
if (!$doEmoticons) {
return $string;
}
$emojiOne = new EmojioneClient(new EmoticonsRuleset());
$emojiOne->ascii = true;
$string = $emojiOne->toImage($string);
$attr = "data-sceditor-emoticon";
$timer = Debug::getTimer();
if (is_string($string)) {
$string = phpQuery::newDocumentHTML($string);
}
//phpQuery::selectDocument($doc);
// Remove #tinymce and .mceContentBody tags
foreach (pq('img') as $e) {
if (pq($e)->attr($attr)) {
$emoticon = pq($e)->attr($attr);
if (strlen($emoticon) > 0) {
pq($e)->replaceWith(str_replace('\\"', "", $emoticon));
}
}
}
Debug::LogEvent(__METHOD__, $timer);
return $string;
}
开发者ID:railpage,项目名称:railpagecore,代码行数:33,代码来源:EmoticonsUtility.php
示例12: RenderImpl
/**
* @see HtmlComponent
*/
public final function RenderImpl()
{
$tag = $this->getTag('table');
pq($tag)->append($this->renderHeader());
pq($tag)->append($this->renderData());
pq($tag)->append($this->renderFooter());
}
开发者ID:Niqpue,项目名称:zippyerp,代码行数:10,代码来源:datatable.php
示例13: getNotas
function getNotas() {
if($this->cursos != null) return $this->cursos;
parent::process();
$this->cursos = array();
$identifier = null;
foreach(pq('table > *:not(thead)') as $bloques) {
if ($bloques->tagName == 'tr') {
if(!$identifier) {
$identifier = pq('td', $bloques)->text();
}
}
else {
$identifier = $identifier ? $identifier : '';
if (!isset($this->notas[$identifier])) $this->notas[$identifier] = array();
foreach(pq('tr', $bloques) as $tr) {
$curso = new stdClass();
$curso->id = pq('td:nth-child(3)', $tr)->html();
$curso->nombre = mb_convert_encoding(pq('td:nth-child(4) > a', $tr)->html(), 'UTF-8');
$curso->url = pq('td:nth-child(4) > a', $tr)->attr('href');
$curso->cargo = UcursosScrapper::toUserType(pq('td:nth-child(1) > img', $tr)->attr('title'));
$curso->institucion = new stdClass();
$curso->institucion->nombre = pq('td:nth-child(2) > img', $tr)->attr('title');
$curso->institucion->icono = pq('td:nth-child(2) > img', $tr)->attr('src');
$this->cursos[$identifier][] = $curso;
}
$identifier = null;
}
}
return $this->cursos;
}
开发者ID:rduenasf,项目名称:ucursos-scrapper,代码行数:31,代码来源:ucursos.cursos.scrapper.php
示例14: createPost
private function createPost(\phpQueryObject $form)
{
$result = [];
foreach ($form->find('input, select, checkbox, textarea') as $input) {
$el = pq($input);
if (($value = $el->attr('example')) || ($value = $el->attr('value'))) {
$result[$el->attr('name')] = $value;
continue;
}
$value = $el->attr('example');
switch ($input->tagName) {
case 'input':
$this->addInput($el, $result, $value);
break;
case 'select':
$this->addSelect($el, $result, $value);
break;
case 'checkbox':
$this->addCheckbox($el, $result, $value);
break;
case 'textarea':
$this->addTextarea($el, $result, $value);
break;
}
}
return $result;
}
开发者ID:bariew,项目名称:yii2-doctest-extension,代码行数:27,代码来源:FormTest.php
示例15: getData
/**
* Implements the getData method
*/
public function getData()
{
//request the url
$this->request(self::URL);
$title = pq('h1.summary:first');
return pq('a', $title)->text();
}
开发者ID:remy22,项目名称:phpquery-crawler,代码行数:10,代码来源:CrawlerPhpnet.php
示例16: getBody
function getBody()
{
if ($this->parts && $this->body === null) {
foreach ($this->parts as $part) {
$partNo = $part['partNo'];
$encoding = $part['encoding'];
$charset = $part['charset'];
$body = imap_fetchbody($this->message->getMailbox(), $this->message->getUID(), $partNo, FT_UID);
$body = BrIMAP::decode($body, $encoding);
if ($charset) {
$body = @iconv($charset, 'UTF-8', $body);
}
$body = trim($body);
$body = preg_replace('~<head[^>]*?>.*?</head>~ism', '', $body);
$body = preg_replace('~<meta[^>]*?>~ism', '', $body);
$body = preg_replace('~<base[^>]*?>~ism', '', $body);
$body = preg_replace('~<style[^>]*?>.*?</style>~ism', '', $body);
if ($this->isHTML && $body) {
try {
$doc = phpQuery::newDocument($body);
$bodyTag = $doc->find('body');
if ($bodyTag->length() > 0) {
$body = trim(pq($bodyTag)->html());
} else {
$body = trim($doc->html());
}
phpQuery::unloadDocuments();
} catch (Exception $e) {
}
}
$this->body .= $body;
}
}
return $this->body;
}
开发者ID:jagermesh,项目名称:bright,代码行数:35,代码来源:BrIMAP.php
示例17: search_query
function search_query($kw)
{
$wf = new Workflows();
$url = 'http://www.bilibili.tv/search?keyword=' . urlencode($kw) . '&orderby=&formsubmit=';
$content = $wf->request($url, array(CURLOPT_ENCODING => 1));
$doc = phpQuery::newDocumentHTML($content);
$list = $doc->find('li.l');
$i = 0;
foreach ($list as $item) {
$link = pq($item)->children('a:first')->attr('href');
if (strpos($link, 'http') !== 0) {
$link = 'http://www.bilibili.tv' . $link;
}
$info = pq($item)->find('div.info > i');
$author = pq($item)->find('a.upper:first')->text();
$view = $info->eq(0)->text();
$comment = $info->eq(1)->text();
$bullet = $info->eq(2)->text();
$save = $info->eq(3)->text();
$date = $info->eq(4)->text();
$subtitle = 'UP主:' . $author . ' 播放:' . $view . ' 评论:' . $comment . ' 弹幕:' . $bullet . ' 收藏:' . $save . ' 日期:' . $date;
$wf->result($i, $link, pq($item)->find('div.t:first')->text(), $subtitle, 'icon.png', 'yes');
$i++;
}
if (count($wf->results()) == 0) {
$wf->result('0', $url, '在bilibili.tv中搜索', $kw, 'icon.png', 'yes');
}
return $wf->toxml();
}
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:29,代码来源:search.php
示例18: finish
public function finish()
{
phpQuery::newDocumentFileHTML($this->downloadUrl, $this->charset);
$nodeCount = pq("#list2")->count();
$articleList = pq("#list2 tr");
echo "Start\n";
for ($i = 0; $i < $this->loop; $i++) {
echo '=';
}
echo "\n";
$i = 0;
foreach ($articleList as $tr) {
$i++;
if ($i <= 1) {
# Filter the first node which has no meaning.
continue;
}
$className = $tr->nodeValue;
# This class order and its name.
$classNameCombine = explode(' ', $className);
$j = 0;
$this->content[$i - 1]['chapterName'] = '';
foreach ($classNameCombine as $k => $v) {
# Put all class order and its name into $this->content array.
$v = trim($v);
if (empty($v)) {
continue;
}
$j++;
if ($j == 1) {
$this->content[$i - 1]['chapterId'] = $v;
} else {
$this->content[$i - 1]['chapterName'] .= $v . " ";
}
}
$child = pq("td", $tr)->html();
$trueContent = explode(' ', $child);
$linkString = '';
foreach ($trueContent as $k => $v) {
$v = trim($v);
if (empty($v)) {
continue;
}
if ($v == "<a") {
$linkString = $v . ' ' . $trueContent[$k + 1];
break;
}
}
$urls = explode("\"", $linkString);
$this->content[$i - 1]['link'] = $urls[1];
// $name = explode("<", $urls[2]);
// $name = substr($name[0], 1);
// $this->content[$i-1]['name'] = $name;
}
var_dump($this->content);
for ($i = 0; $i < $this->loop; $i++) {
echo '=';
}
echo "\nFinished! \n";
}
开发者ID:niceforbear,项目名称:ohyeah,代码行数:60,代码来源:Ohyeah.php
示例19: service
function service($nik)
{
$default = ['wilayah_id' => '0', 'g-recaptcha-response' => '000', 'cmd' => 'Cari.', 'page' => '', 'nik_global' => $nik];
$params = $default;
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'http://data.kpu.go.id/ss8.php', ['form_params' => $params]);
$html = $res->getBody();
$startsAt = strpos($html, '<body onload="loadPage()">') + strlen('<body onload="loadPage()">');
$endsAt = strpos($html, '</body>', $startsAt);
$result = substr($html, $startsAt, $endsAt - $startsAt);
// return $html;
$dom = phpQuery::newDocumentHTML($result);
// return $dom;
$result = [];
foreach (pq('div.form') as $content) {
$key = snake(preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', rtrim(trim(pq($content)->find('.label')->eq(0)->html()), ':')));
$value = preg_replace('/[\\x00-\\x1F\\x80-\\xFF]/', '', rtrim(trim(pq($content)->find('.field')->eq(0)->html()), ':'));
if (empty($key)) {
continue;
}
$result[$key] = $value;
}
if (!empty($result)) {
echo json_encode(['success' => true, 'message' => 'Success', 'data' => $result]);
} else {
http_response_code(400);
echo json_encode(['success' => false, 'message' => 'Data tidak ditemukan']);
}
}
开发者ID:mrofi,项目名称:database-wilayah-indonesia,代码行数:29,代码来源:ktp.php
示例20: testShowData
function testShowData()
{
$handler = new Doku_Handler();
$xhtml = new Doku_Renderer_xhtml();
$plugin = new syntax_plugin_data_entry();
$result = $plugin->handle($this->exampleEntry, 0, 10, $handler);
$plugin->_showData($result, $xhtml);
$doc = phpQuery::newDocument($xhtml->doc);
$this->assertEquals(1, pq('div.inline.dataplugin_entry.projects', $doc)->length);
$this->assertEquals(1, pq('dl dt.type')->length);
$this->assertEquals(1, pq('dl dd.type')->length);
$this->assertEquals(1, pq('dl dt.volume')->length);
$this->assertEquals(1, pq('dl dd.volume')->length);
$this->assertEquals(1, pq('dl dt.employee')->length);
$this->assertEquals(1, pq('dl dd.employee')->length);
$this->assertEquals(1, pq('dl dt.customer')->length);
$this->assertEquals(1, pq('dl dd.customer')->length);
$this->assertEquals(1, pq('dl dt.deadline')->length);
$this->assertEquals(1, pq('dl dd.deadline')->length);
$this->assertEquals(1, pq('dl dt.server')->length);
$this->assertEquals(1, pq('dl dd.server')->length);
$this->assertEquals(1, pq('dl dt.website')->length);
$this->assertEquals(1, pq('dl dd.website')->length);
$this->assertEquals(1, pq('dl dt.task')->length);
$this->assertEquals(1, pq('dl dd.task')->length);
$this->assertEquals(1, pq('dl dt.tests')->length);
$this->assertEquals(1, pq('dl dd.tests')->length);
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:28,代码来源:syntax_plugin_data_entry.test.php
注:本文中的pq函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论