示例#1
0
 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;
 }
示例#2
0
 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;
 }
 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 &shy; will be added to links for example
         if ($strText != strip_tags($strText)) {
             continue;
         }
         $strText = str_replace('&shy;', '', $strText);
         // remove manual &shy; html entities before
         $strText = $h->hyphenate($strText);
         if (is_array($strText)) {
             $strText = current($strText);
         }
         pq($item)->html($strText);
     }
     return $doc->htmlOuter();
 }
    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;
    }
示例#5
0
 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();
 }
示例#6
0
 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
 }
示例#7
0
 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;
     }
 }
    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;
    }
示例#9
0
 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;
 }
示例#10
0
 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));
 }
示例#11
0
 /**
  * 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;
 }
示例#12
0
 /**
  * @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());
 }
    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;
    }
示例#14
0
 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;
 }
示例#15
0
 /**
  * Implements the getData method
  */
 public function getData()
 {
     //request the url
     $this->request(self::URL);
     $title = pq('h1.summary:first');
     return pq('a', $title)->text();
 }
示例#16
0
 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;
 }
示例#17
0
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();
}
示例#18
0
 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";
 }
示例#19
0
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']);
    }
}
 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);
 }
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);
}
示例#22
0
function insert_to_vm_panda($id_category, $UURRLL)
{
    global $conn;
    pq_page($UURRLL);
    $res_items = pq('ul.products-grid>li');
    foreach ($res_items as $item) {
        try {
            $ii = pq($item);
            $hhq = $ii->html();
            $productUrl = $ii->find('a.product-image')->attr('href');
            $sql1 = "select count(*) as count from _products where url='{$productUrl}' limit 1";
            $res = run_sql($sql1);
            // $res = mysql_query($sql1, $conn)or die("Invalid query: " . mysql_error());;
            $data = mysql_fetch_assoc($res);
            if ($data[count] == 0) {
                $imgSmallUrl = $ii->find("img")->attr('taikoo_lazy_src');
                $product_name = $ii->find('.product-name>a')->text();
                $product_sql = "INSERT _products (url, ids_category, name, img_small, status)\n                            VALUES ('{$productUrl}', {$id_category}, '{$product_name}', '{$imgSmallUrl}', 1)";
                run_sql($product_sql);
            } else {
                $sql1 = "select * from _products where url='{$productUrl}' limit 1";
                $res = run_sql($sql1);
                $data2 = mysql_fetch_assoc($res);
                $category_old_value = (string) $data2[ids_category];
                $sql = " UPDATE _products SET ids_category='{$category_old_value},{$id_category}' WHERE url='{$productUrl}'";
                run_sql($sql);
            }
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
        }
    }
    return $res;
}
示例#23
0
 public function getAllData()
 {
     $url = $this->getWebsiteUrl();
     $parser = new Parser();
     $html = $parser->getHtml($url);
     phpQuery::newDocumentHTML($html);
     $data = array();
     $data['logo'] = $this->getLogo();
     $data['sitename'] = "Sulekha.com";
     foreach (pq(".box") as $item) {
         $class_Discount_bg = pq($item)->find(".dealimgst");
         $href = pq($class_Discount_bg)->find("a")->attr("href");
         $href = 'http://deals.sulekha.com' . $href;
         $actual_price = trim(pq($item)->find(".dlpristrk")->text());
         $actual_price = (int) preg_replace('~\\D~', '', $actual_price);
         $img_src = pq($class_Discount_bg)->find("img")->attr("src");
         $price = trim(pq($item)->find(".hgtlgtorg")->text());
         $price = (int) preg_replace('~\\D~', '', $price);
         $off_percent = $actual_price - $price;
         $off_percent = number_format($off_percent) . "/-";
         $price = number_format($price) . "/-";
         $name = trim(pq($item)->find(".deallstit>a")->text());
         //$time_left = pq($item)->find(".countdown_row")->text();
         $data[] = array('name' => $name, 'href' => $href, 'price' => 'Rs.' . $price, 'image' => $img_src, 'off' => 'Rs.' . $off_percent);
     }
     return $data;
 }
示例#24
0
 /**
  * Implements the getData method
  */
 public function getData()
 {
     //request the url
     $this->request(self::URL);
     $title = pq('div#content div.newsItem h1:first');
     echo pq('a', $title)->text();
 }
示例#25
0
 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");
 }
示例#26
0
 public function assignPageContent(\phpQueryObject $_)
 {
     parent::assignPageContent($_);
     $this->_seasons = [];
     foreach ($_['a[href^="/title/' . $this->_id . '/episodes?season="]'] as $seasonLink) {
         $this->_seasons[] = (int) pq($seasonLink)->text();
     }
 }
示例#27
0
function moegirl_analysis($text)
{
    $content = file_get_contents(moegirl_url($text));
    $doc = phpQuery::newDocumentHTML($content);
    phpQuery::selectDocument($doc);
    $ansList = pq(".NetDicBody");
    $ans = 0;
}
 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;
 }
示例#29
0
 protected function _processHtml($return_raw, &$np)
 {
     // Query document for tables with stream data.
     $pq = \phpQuery::newDocument($return_raw);
     $mounts = array();
     $tables_1 = $pq->find('table:has(td.streamdata)');
     if ($tables_1->length > 0) {
         $tables = $tables_1;
         $table_selector = 'td.streamdata';
     } else {
         return false;
     }
     foreach ($tables as $table) {
         $streamdata = pq($table)->find($table_selector);
         $mount = array();
         $i = 0;
         foreach ($streamdata as $cell) {
             $pq_cell = pq($cell);
             $cell_name = $pq_cell->prev()->html();
             $cell_name_clean = preg_replace('/[^\\da-z_]/i', '', str_replace(' ', '_', strtolower($cell_name)));
             $cell_value = trim($pq_cell->html());
             if (!empty($cell_name_clean) && !empty($cell_value)) {
                 $mount[$cell_name_clean] = $cell_value;
             }
             $i++;
         }
         $mounts[] = $mount;
     }
     if (count($mounts) == 0) {
         return false;
     }
     $active_mounts = array();
     foreach ($mounts as $mount) {
         if (count($mount) >= 9) {
             $active_mounts[] = $mount;
         }
     }
     if (count($active_mounts) == 0) {
         return false;
     }
     // Sort in descending order of listeners.
     usort($active_mounts, function ($a, $b) {
         $a_list = (int) $a[5];
         $b_list = (int) $b[5];
         if ($a_list == $b_list) {
             return 0;
         } else {
             return $a_list > $b_list ? -1 : 1;
         }
     });
     $temp_array = $active_mounts[0];
     $np['current_song'] = $this->getSongFromString($temp_array['current_song'], ' - ');
     $np['meta']['status'] = 'online';
     $np['meta']['bitrate'] = $temp_array['bitrate'];
     $np['meta']['format'] = $temp_array['content_type'];
     $np['listeners']['current'] = (int) $temp_array['current_listeners'];
     return true;
 }
示例#30
0
 public function getAnyImg($page, $selectors, $return, $dop)
 {
     $result = '';
     $html = phpQuery::newDocument($page);
     foreach ($html->find($selectors) as $e) {
         $result .= pq($e)->{$return}($dop);
     }
     return $result;
 }