本文整理汇总了PHP中Page::content方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::content方法的具体用法?PHP Page::content怎么用?PHP Page::content使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::content方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scrap_page
private function scrap_page($url)
{
$base_url = 'http://' . parse_url($url, PHP_URL_HOST);
$p = new Page($url);
$h = new simple_html_dom();
$h->load($p->content());
$boxes = $h->find('.textbox');
$result = array();
foreach ($boxes as $box) {
// image/url
$content = $box->find('.textbox-content', 0);
$url = $base_url . $content->find('a', 0)->href;
$thumb = $base_url . $content->find('img', 0)->src;
// other data
$label = $box->find('.webcss-label', 0);
$title = $label->find('p', 0)->find('a', 0)->innertext;
$title = html_entity_decode($title, ENT_COMPAT, 'UTF-8');
$h2 = $label->find('h2', 0);
$date = Text::create($h2->innertext)->cut_after('>:')->to_s();
$h5 = $label->find('h5', 0);
$tags = Text::create($h5->innertext)->strip_tags()->cut_after(':')->to_s();
$tags = array_filter(explode(',', $tags), 'trim');
$view = $label->find('.webcss_view', 0);
$m = Text::create($view->innertext)->regex_match('/(\\d+)/');
$pages = $m[1];
$item = array('title' => $title, 'url' => $url, 'date' => $date, 'pages' => $pages, 'thumb' => $thumb, 'tags' => '#' . implode('#', $tags) . '#');
$result[] = $item;
}
return array_reverse($result);
}
示例2: buildPage
function buildPage($key)
{
global $dbPages;
global $dbUsers;
global $Parsedown;
global $Site;
// Page object, content from FILE.
$Page = new Page($key);
if (!$Page->isValid()) {
Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying build the page from file with key: ' . $key);
return false;
}
// Page database, content from DATABASE JSON.
$db = $dbPages->getPageDB($key);
if (!$db) {
Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying build the page from database with key: ' . $key);
return false;
}
// Foreach field from DATABASE.
foreach ($db as $field => $value) {
$Page->setField($field, $value);
}
// Content in raw format
$contentRaw = $Page->content();
$Page->setField('contentRaw', $Page->content(), true);
// Parse markdown content.
$content = Text::pre2htmlentities($contentRaw);
// Parse pre code with htmlentities
$content = $Parsedown->text($content);
// Parse Markdown.
$content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS);
// Parse img src relative to absolute.
$Page->setField('content', $content, true);
// Pagebrake
$explode = explode(PAGE_BREAK, $content);
$Page->setField('breakContent', $explode[0], true);
$Page->setField('readMore', !empty($explode[1]), true);
// Date format
$pageDate = $Page->date();
$Page->setField('dateRaw', $pageDate, true);
$pageDateFormated = $Page->dateRaw($Site->dateFormat());
$Page->setField('date', $pageDateFormated, true);
// User object
$username = $Page->username();
$Page->setField('user', $dbUsers->getUser($username));
return $Page;
}
示例3: content
public final function content()
{
// if ($this->isCached($this->id('content'))) {
// return $this->get($this->id('content'));
// } else {
return parent::content();
// }
}
示例4: open
private function open($url)
{
echo "Opening {$url}...\n";
$p = new Page($url);
$h = new simple_html_dom();
$h->load($p->content());
return $h;
}
示例5: build_page
function build_page($key)
{
global $dbPages;
global $dbUsers;
global $Parsedown;
global $Site;
// Page object, content from FILE.
$Page = new Page($key);
if (!$Page->isValid()) {
Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying build the page from file with key: ' . $key);
return false;
}
// Page database, content from DATABASE JSON.
$db = $dbPages->getDb($key);
if (!$db) {
Log::set(__METHOD__ . LOG_SEP . 'Error occurred when trying build the page from database with key: ' . $key);
return false;
}
// Foreach field from DATABASE.
foreach ($db as $field => $value) {
$Page->setField($field, $value);
}
// Content in raw format
$contentRaw = $Page->content();
$Page->setField('contentRaw', $Page->content(), true);
// Parse markdown content.
$content = Text::pre2htmlentities($contentRaw);
// Parse pre code with htmlentities
$content = $Parsedown->text($content);
// Parse Markdown.
$content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS);
// Parse img src relative to absolute.
$Page->setField('content', $content, true);
// Date format
$pageDate = $Page->date();
$Page->setField('dateRaw', $pageDate, true);
$pageDateFormated = $Page->dateRaw($Site->dateFormat());
$Page->setField('date', $pageDateFormated, true);
// Parse username for the page.
if ($dbUsers->userExists($Page->username())) {
$user = $dbUsers->getDb($Page->username());
$Page->setField('authorFirstName', $user['firstName'], false);
$Page->setField('authorLastName', $user['lastName'], false);
}
return $Page;
}
示例6: create_dom
private function create_dom($url)
{
echo "Opening {$url}\n";
$p = new Page($url, array(CURLOPT_COOKIE => 'nw=1'));
$h = new simple_html_dom();
$h->load($p->content());
return $h;
}
示例7: collect_images
private function collect_images($url, $dir)
{
if (strpos($url, '/idol.')) {
$base = 'https://idol.sankakucomplex.com';
} else {
$base = 'https://chan.sankakucomplex.com';
}
$page = $this->page_from;
$id = 1;
$Turl = Text::create($url);
do {
if ($page > $this->page_to) {
break;
}
$purl = $url . '&page=' . $page;
echo "{$purl}\n";
do {
$P = new Page($purl, array('become_firefox' => true));
$T = new Text($P->content());
sleep(3);
// 429 too many requests
} while ($T->contain('429 Too many requests'));
$a = $T->extract_to_array('href="', '"');
foreach ($a as $i => $e) {
$E = new Text($e);
if (!$E->contain('/post/show')) {
unset($a[$i]);
}
}
if (!count($a)) {
break;
}
foreach ($a as $i => $e) {
$E = new Text($e);
$kurl = $base . $e;
echo "{$kurl}\n";
flush();
do {
$P = new Page($kurl, array('become_firefox' => true));
$T = new Text($P->content());
sleep(3);
// 429 too many requests
} while ($T->contain('429 Too many requests'));
$P->go_line('id=highres');
$img = $P->curr_line()->cut_between('href="', '"');
/*if ($img->contain('.webm')) {
echo "This is WEBM\n";
} else*/
if ($img->to_s()) {
$this->download_if_not_exist($img, $dir, $id);
$id++;
} else {
echo "No id=highres\n";
}
}
$page++;
} while (true);
}
示例8: build_page
function build_page($key)
{
global $dbPages;
global $dbUsers;
global $Parsedown;
// Page object.
$Page = new Page($key);
if (!$Page->isValid()) {
return false;
}
// Page database.
$db = $dbPages->getDb($key);
if (!$db) {
return false;
}
// Foreach field from database.
foreach ($db as $field => $value) {
if ($field == 'unixTimeCreated') {
// Format dates, not overwrite from file fields.
$Page->setField('unixTimeCreated', $value, false);
$Page->setField('date', Date::format($value, '%d %B'), false);
$Page->setField('timeago', Date::timeago($value), false);
} else {
// Other fields, not overwrite from file fields.
$Page->setField($field, $value, false);
}
}
// Content in raw format
$contentRaw = $Page->content();
$Page->setField('contentRaw', $Page->content(), true);
// Parse markdown content.
$content = $Parsedown->text($contentRaw);
// Parse Markdown.
$content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS);
// Parse img src relative to absolute.
$Page->setField('content', $content, true);
// Parse username for the page.
if ($dbUsers->userExists($Page->username())) {
$user = $dbUsers->getDb($Page->username());
$Page->setField('authorFirstName', $user['firstName'], false);
$Page->setField('authorLastName', $user['lastName'], false);
}
return $Page;
}
示例9: extract
public function extract($columns, $s, $n, $url)
{
$result = array();
$p = new Page($url);
$h = new simple_html_dom();
$h->load($p->content());
$pinbin = $h->find('.pinbin-copy', 0);
foreach ($pinbin->find('img') as $img) {
$item = array('image' => $img->outertext());
$result[] = $item;
}
return $result;
}
示例10: extract
public function extract($columns, $s, $n, $url)
{
$result = array();
if (strpos($url, 'http://www.rlsbb.com') === 0) {
$url = str_replace('http://www.rlsbb.com', 'http://rlsbb.com', $url);
}
for ($i = $s; $i <= $n; $i++) {
$purl = rtrim($url, '/') . '/';
if ($i > 1) {
$purl .= 'page/' . $i . '/';
}
$p = new Page($purl);
$h = new simple_html_dom();
$h->load($p->content());
foreach ($h->find('div.post') as $post) {
$item = array();
$title_a = $post->find('.postTitle', 0)->find('a', 0);
$item['link'] = "<a href='{$title_a->href}'>link</a>";
$title_a = $post->find('.postTitle', 0)->find('a', 0);
$item['title'] = $title_a->innertext;
$subtitle = $post->find('.postSubTitle', 0);
$date = Text::create($subtitle->innertext)->regex_match('/Posted on (.*) in </');
$date = $date[1];
$item['date'] = $date;
$subtitle = $post->find('.postSubTitle', 0);
$categories = array();
foreach ($subtitle->find('a[rel=category tag]') as $c) {
$categories[] = $c->innertext;
}
$item['categories'] = implode(', ', $categories);
$content = $post->find('.postContent', 0);
if (!$content) {
$content = $post->find('.entry-content', 0);
}
$item['content'] = strip_tags($content->innertext, '<br>');
$item['description'] = $item['content'];
$content = $post->find('.postContent', 0);
if (!$content) {
$content = $post->find('.entry-content', 0);
}
$img = $content->find('img', 0);
$item['image'] = $img ? $img->outertext() : '';
$img2 = $content->find('img', 1);
$item['image2'] = $img2 ? $img2->outertext() : '';
$img3 = $content->find('img', 2);
$item['image3'] = $img3 ? $img3->outertext() : '';
$result[] = $item;
}
}
return $result;
}
示例11: build_page
function build_page($key)
{
global $dbPages;
global $dbUsers;
global $Parsedown;
// Page object, content from FILE.
$Page = new Page($key);
if (!$Page->isValid()) {
return false;
}
// Page database, content from DATABASE JSON.
$db = $dbPages->getDb($key);
if (!$db) {
return false;
}
// Foreach field from DATABASE.
foreach ($db as $field => $value) {
$Page->setField($field, $value);
}
// Content in raw format
$contentRaw = $Page->content();
$Page->setField('contentRaw', $Page->content(), true);
// Parse markdown content.
$content = Text::pre2htmlentities($contentRaw);
// Parse pre code with htmlentities
$content = $Parsedown->text($content);
// Parse Markdown.
$content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS);
// Parse img src relative to absolute.
$Page->setField('content', $content, true);
// Parse username for the page.
if ($dbUsers->userExists($Page->username())) {
$user = $dbUsers->getDb($Page->username());
$Page->setField('authorFirstName', $user['firstName'], false);
$Page->setField('authorLastName', $user['lastName'], false);
}
return $Page;
}
示例12: extract
public function extract($columns, $s, $n, $url)
{
$result = array();
for ($i = $s; $i <= $n; $i++) {
$purl = rtrim($url, '/') . '/';
if ($i > 1) {
$purl .= 'page/' . $i . '/';
}
$p = new Page($purl);
$h = new simple_html_dom();
$h->load($p->content());
foreach ($h->find('div.post') as $post) {
$item = array();
if (in_array('link', $columns)) {
$title_a = $post->find('h2', 0)->find('a', 0);
$item['link'] = "<a href='{$title_a->href}'>link</a>";
}
if (in_array('title', $columns)) {
$title_a = $post->find('h2', 0)->find('a', 0);
$item['title'] = $title_a->innertext;
}
if (in_array('date', $columns)) {
$date = $post->find('span.date', 0);
$item['date'] = $date->innertext;
}
if (in_array('category', $columns)) {
$meta = $post->find('div.meta', 0);
$categories = array();
foreach ($meta->find('a[rel=category tag]') as $c) {
$categories[] = $c->innertext;
}
$item['categories'] = implode(', ', $categories);
}
if (in_array('content', $columns)) {
$content = $post->find('.storycontent', 0);
$item['content'] = strip_tags($content->innertext, '<br>');
}
if (in_array('image', $columns)) {
$content = $post->find('.storycontent', 0);
$img = $content->find('img', 0);
$item['image'] = $img ? $img->outertext() : '';
$img2 = $content->find('img', 1);
$item['image2'] = $img2 ? $img2->outertext() : '';
}
$result[] = $item;
}
}
return $result;
}
示例13: get_images
public function get_images($chapter_url, $prefix, $infix)
{
$ifx = Text::create($infix)->pad(3)->to_s();
$p = new Page($chapter_url);
$h = new simple_html_dom();
$h->load($p->content());
$select = $h->find('select[name="pagejump"]', 0);
$img = $h->find('#page', 0)->find('img', 0);
$srcdir = dirname($img->src);
$pages = array();
foreach ($select->find('option') as $opt) {
$pages["{$prefix}-{$infix}-{$opt->value}.jpg"] = $srcdir . '/' . $opt->value . '.jpg';
}
return $pages;
}
示例14: get_info
public function get_info($base)
{
$domain = 'http://www.mangaeden.com';
$p = new Page($base);
$h = new simple_html_dom();
$h->load($p->content());
$links = $h->find('.chapterLink');
$list = array();
foreach ($links as $a) {
$url = $domain . $a->href;
$desc = $a->find('b', 0)->innertext();
$list[] = array('url' => $url, 'desc' => $desc, 'infix' => $this->get_infix($url));
}
return $list;
}
示例15: get_info
public function get_info($base)
{
$DOMAIN = 'http://kissmanga.com';
// crawl chapters
$p = new Page($base, array('become_firefox' => true));
$h = new simple_html_dom();
$h->load($p->content());
$table = $h->find('table.listing', 0);
$list = array();
foreach ($table->find('a') as $a) {
$href = $DOMAIN . $a->href;
$desc = $a->title;
$infix = $this->get_infix($href);
$list[] = array('url' => $href, 'desc' => $desc, 'infix' => $infix);
}
return $list;
}