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


PHP phpQuery::selectDocument方法代码示例

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


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

示例1: getAllSubCategories

function getAllSubCategories($filename)
{
    $categories = unserialize(file_get_contents($filename));
    echo "---- run getAllSubCategories() ----\n\r";
    foreach ($categories as $j => $category) {
        if ($category['childrens']) {
            foreach ($category['childrens'] as $k => $children) {
                echo "---- crawling childrens for {$children['name']} ----\n\r";
                $doc = phpQuery::newDocumentHTML(fetch('http://www.walmart.com' . $children['link']));
                phpQuery::selectDocument($doc);
                foreach (pq('.shop-by-category li') as $el) {
                    echo "---- " . pq($el)->find('a')->attr('href') . "} ----\n\r";
                    $childrens[] = array('name' => pq($el)->find('a')->data('name'), 'link' => pq($el)->find('a')->attr('href'));
                }
                $categories[$j]['childrens'][$k]['childrens'] = $childrens;
            }
        }
    }
    echo "---- creating deparment file ----\n\r";
    $file = fopen($filename, 'w+');
    echo "---- writing deparment file ----\n\r";
    fputs($file, serialize($categories));
    echo "---- closing deparment file ----\n\r";
    fclose($file);
}
开发者ID:josueaponte7,项目名称:necotienda_standalone,代码行数:25,代码来源:walmart-v-0.1.php

示例2: theContent

 function theContent($content)
 {
     $doc = phpQuery::newDocumentHTML($content);
     phpQuery::selectDocument($doc);
     foreach (pq('a') as $link) {
         $linkurl = pq($link)->attr('href');
         $linkHostname = $this->getUrlHostname($linkurl);
         if ($linkHostname != FALSE) {
             if (!in_array($linkHostname, $this->blockedDomains)) {
                 $linkHash = md5($linkurl);
                 $query = "SELECT * FROM {$this->tableBitlyExternal} WHERE id='{$linkHash}'LIMIT 1;";
                 $linkData = $this->db->get_row($query, ARRAY_A);
                 if (empty($linkData)) {
                     $bitly = new Bitly($this->bitlyUsername, $this->bitlyApikey);
                     $shortURL = $bitly->shorten($linkurl);
                     $shortURLData = get_object_vars($bitly->getData());
                     if (!empty($shortURLData)) {
                         $linkData = array('id' => $linkHash, 'url' => $linkurl, 'short_url' => $shortURLData['shortUrl'], 'hash' => $shortURLData['userHash'], 'created' => current_time('mysql'));
                         $this->db->insert($this->tableBitlyExternal, $linkData);
                     }
                 }
                 if (!empty($linkData)) {
                     pq($link)->attr('href', $linkData['short_url']);
                 }
             }
         }
     }
     return $doc->htmlOuter();
 }
开发者ID:hmimthiaz,项目名称:bitly-external,代码行数:29,代码来源:bitly-external.php

示例3: process

 function process() {
     if (!$this->processed) {
         $this->processed = true;
         $this->phpQueryDocument = phpQuery::newDocumentHTML($this->content);
         phpQuery::selectDocument($this->phpQueryDocument);
     }
 }
开发者ID:rduenasf,项目名称:ucursos-scrapper,代码行数:7,代码来源:library.ucursos.scrapper.php

示例4: moegirl_analysis

function moegirl_analysis($text)
{
    $content = file_get_contents(moegirl_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq(".NetDicBody");
    $ans = 0;
}
开发者ID:sagitrs,项目名称:php,代码行数:8,代码来源:moegirl_analysis.php

示例5: wikipedia_analysis

function wikipedia_analysis($text)
{
    $content = file_get_contents(wikipedia_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq(".NetDicBody");
    $ans = 0;
    return $doc;
}
开发者ID:sagitrs,项目名称:php,代码行数:9,代码来源:wikipedia_analysis.php

示例6: parseHtml

 /**
  * @param $conf ConfNode
  * @param $html
  * @return array|float|int|String
  */
 public static function parseHtml($conf, $html)
 {
     query::$defaultCharset = "utf-8";
     $doc = query::newDocument($html);
     query::selectDocument($doc);
     $value = self::queryValue(pq($doc), $conf);
     //清理内存
     query::unloadDocuments($doc);
     return $value;
 }
开发者ID:xiaozhu-life,项目名称:spider-php,代码行数:15,代码来源:HtmlParser.php

示例7: parseVCard

 /**
  * Parse <a href="http://onesocialweb.org/spec/1.0/osw-vcard4.html">VCard4 over XMPP</a>.
  * @param String $xml
  */
 public function parseVCard($xml)
 {
     // TODO ACL
     $this->logger->debug("parseVCard: '{$xml}'");
     $doc = \phpQuery::newDocument($xml);
     \phpQuery::selectDocument($doc);
     $this->fn = pq('vcard fn text')->text();
     $this->note = pq('vcard note text')->text();
     $this->photo = pq('vcard photo uri')->text();
     $this->logger->debug("fn: '{$this->fn}'");
     $this->logger->debug("note: '{$this->note}'");
     $this->logger->debug("photo: '{$this->photo}'");
 }
开发者ID:sdrieling,项目名称:osw-RPOSWWebClient,代码行数:17,代码来源:Profile.php

示例8: Render

 /**
  * @see  HtmlComponent
  */
 public function Render()
 {
     // $template =
     $htmltag = $this->getTag();
     $template = WebApplication::getApplication()->getTemplate(get_class($this));
     $qid = \phpQuery::getDocumentID($htmltag);
     $doc = \phpQuery::newDocumentHTML($template);
     $htmltag->replaceWith($doc['body']->html());
     //$htmltag->html($doc['body']->html());
     \phpQuery::selectDocument($qid);
     $this->beforeRender();
     parent::RenderImpl();
     $this->afterRender();
 }
开发者ID:leon-mbs,项目名称:zippy,代码行数:17,代码来源:pagefragment.php

示例9: goo_analysis

function goo_analysis($text)
{
    $content = file_get_contents(goo_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq("#NR-main > section > div > section:nth-child(2) > div > ul > li");
    $ans = 0;
    $ret = "<br />";
    //    echo $ret;
    foreach ($ansList as $li) {
        //        echo pq($li)->html().$ret;
        $ans++;
        //        echo "----------------------------------------------------------------";
    }
    return $ans;
}
开发者ID:sagitrs,项目名称:php,代码行数:16,代码来源:goo_analysis.php

示例10: weblio_analysis

function weblio_analysis($text)
{
    $content = file_get_contents(weblio_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq(".NetDicBody");
    $ans = 0;
    $ret = "<br />";
    //    echo $ret;
    foreach ($ansList as $li) {
        //        echo pq($li)->html().$ret;
        $ans++;
        //        echo "----------------------------------------------------------------";
    }
    return $ans;
}
开发者ID:sagitrs,项目名称:php,代码行数:16,代码来源:weblio_analysis.php

示例11: hj_analysis

function hj_analysis($text)
{
    $content = file_get_contents(hj_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq("#headword_div");
    $ans = array();
    $ret = "<br />";
    for ($i = 1; $i < 10; $i++) {
        $key = "#jpword_" . $i;
        $res = pq($doc)->find($key)->text();
        if ($res != '') {
            //            echo $key.$ret;
            //            echo "[$i]:>>".$res."<<".$ret;
            array_push($ans, $res);
        }
    }
    return sizeof($ans);
    //    return $content;
}
开发者ID:sagitrs,项目名称:php,代码行数:20,代码来源:hj_analysis.php

示例12: getWithPHPQuery

 private function getWithPHPQuery($selectors)
 {
     require 'phpQuery/phpQuery.php';
     $content = file_get_contents($selectors['url']);
     $doc = phpQuery::newDocumentHTML($content);
     phpQuery::selectDocument($doc);
     $renders = [];
     $items = pq($selectors['item']);
     $items->each(function ($t) {
         if ($selectors['link'] == '.') {
             $item['title'] = pq($t)->text();
         } else {
             $item['title'] = pq($t)->find($selectors['title'])->text();
         }
         if ($selectors['link'] == '.') {
             $item['link'] = pg($t)->getAttribute('href');
         } else {
             $item['link'] = pg($t)->find($selectors['link'])->getAttribute('href');
         }
         $item['digest'] = pg($t)->find($selectors['description'])->text();
         $renders[] = $item;
     });
     return $renders;
 }
开发者ID:yisonvest,项目名称:popnews-ui,代码行数:24,代码来源:NewsController.php

示例13: preg_replace

 $str = preg_replace(array('`[^a-z0-9]`i', '`[-]+`'), '-', $str);
 $str = strtolower(trim($str, '-'));
 if (!file_exists($filename . '.txt')) {
     $href = pq($el)->attr('href');
     $categorias[] = array('name' => pq($el)->text(), 'alias' => $str, 'url' => $href);
 } else {
     $categorias = unserialize(file_get_contents($filename . '.txt'));
     echo "File load it\n";
     foreach ($categorias as $children) {
         if (!file_exists(str_replace('links', 'customers', $filename) . '-' . $children['alias'] . '.txt')) {
             $links = array();
             echo "Children load it for url: {$children['url']}\n";
             $pages = ['', 'p-2/', 'p-3/', 'p-4/', 'p-5/', 'p-6/', 'p-7/', 'p-8/', 'p-9/', 'p-10/', 'p-11/', 'p-12/', 'p-13/', 'p-14/', 'p-15/', 'p-16/', 'p-17/', 'p-18/', 'p-19/', 'p-20/', 'p-21/', 'p-22/', 'p-23/', 'p-24/', 'p-25/', 'p-26/', 'p-27/', 'p-28/', 'p-29/', 'p-30/'];
             foreach ($pages as $page) {
                 $doc = phpQuery::newDocumentHTML(fetch($children['url'] . $page));
                 phpQuery::selectDocument($doc);
                 foreach (pq('ul.m-results-businesses > li') as $el) {
                     $email = pq($el)->find('.m-result-business--question-form-emails input[name=mailAnunciante]')->val();
                     if (empty($email)) {
                         $email = [];
                         foreach (pq($eq)->find('.m-result-business--question-form-emails select[name=mailAnunciante] option') as $option) {
                             $email[] = pq($option)->val();
                         }
                     }
                     $name = pq($el)->find('h3.itemprop=[name] a')->text();
                     $phone = pq($el)->find('p.itemprop=[telephone]')->text();
                     $website = pq($el)->find('.m-results-business--online a.itemprop=[url]')->attr('href');
                     $links[] = ['email' => $email, 'name' => $name, 'phone' => $phone, 'website' => $website];
                 }
             }
             $file = fopen(str_replace('links', 'customers', $filename) . '-' . $children['alias'] . '.txt', 'w+');
开发者ID:josueaponte7,项目名称:necotienda_standalone,代码行数:31,代码来源:amarillas-cl.php

示例14: search

 function search($q, $el = null)
 {
     switch ($this->parserType) {
         case 'simple':
             $doc = $el ? $this->parser->find('#' . $el) : $this->parser;
             $result = $doc->find($q);
             return $result;
         case 'phpquery':
             phpQuery::selectDocument($this->parser);
             $doc = $el ? pq($el) : $this->parser;
             return $doc->find($q);
         default:
             return $this->xpath->query($q, $el);
     }
 }
开发者ID:bsa-git,项目名称:zf-myblog,代码行数:15,代码来源:PGBrowser.php

示例15: getAndParseActivities

    /**
     * Returns inbox of login or activities of given JID.
     *
     * @param string $jid
     * @param string $box 'inbox' or 'activities'
     */
    private function getAndParseActivities($jid, $box = 'activities')
    {
        $activities = array();
        $node = 'urn:xmpp:microblog:0';
        if ('inbox' == $box) {
            $node = 'http://onesocialweb.org/spec/1.0/inbox';
        }
        /*
                 <iq type="error" id="get1" from="alice@example.org/client" to="bob@example.org/work"><pubsub xmlns="http://jabber.org/protocol/pubsub">
          <items node="urn:xmpp:microblog:0"/>
        </pubsub><error code="503" type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
        */
        $payload = <<<EOD
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
  <items node='{$node}'/>
</pubsub>
EOD;
        $id = $this->idCount++;
        $this->sendIQ($id, $payload, 'get', null, $jid);
        $this->read('iq', $id);
        $stanza = $this->stanzaParser->removeStanza('iq', $id);
        $xml = $stanza->__toString();
        $doc = \phpQuery::newDocument($xml);
        \phpQuery::selectDocument($doc);
        foreach (pq('iq pubsub items item') as $item) {
            $a = new Activity();
            $a->id = pq($item)->attr('id');
            // TODO Check
            $entry = pq($item)->find('entry');
            $a->title = pq($entry)->find('title')->text();
            $a->actor = pq($entry)->find('actor uri')->text();
            $a->inReplyTo = pq($entry)->find('in-reply-to')->attr('href');
            $a->published = pq($entry)->find('published')->text();
            if (!\is_null($a->published)) {
                $a->published = \strtotime($a->published);
            }
            $type = pq($entry)->find('acl-rule acl-subject:first')->attr('type');
            // TODO Read all rules
            $name = pq($entry)->find('acl-rule acl-subject:first')->text();
            switch ($type) {
                case Activity::$EVERYONE:
                    $a->viewable = 'Everyone';
                    $a->toType = Activity::$EVERYONE;
                    break;
                case Activity::$GROUP:
                    $a->viewable = "Group: {$name}";
                    $a->toType = Activity::$GROUP;
                    $a->to = $name;
                    break;
                case Activity::$PERSON:
                    $a->viewable = "Person: {$name}";
                    $a->toType = Activity::$PERSON;
                    $a->to = $name;
                    break;
                default:
                    $a->viewable = "Unknown T: '{$type}' N: '{$name}'";
                    $this->logger->error($a->viewable);
                    break;
            }
            // switch($type)
            $activities[] = $a;
        }
        // foreach(pq('iq pubsub items item') as $item)
        return $activities;
    }
开发者ID:sdrieling,项目名称:osw-RPOSWWebClient,代码行数:71,代码来源:XMPP.php


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