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


PHP Text::create方法代码示例

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


在下文中一共展示了Text::create方法的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);
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:30,代码来源:FreeHManga.php

示例2: get_images

 public function get_images($chapter_url, $prefix, $infix)
 {
     $ifx = Text::create($infix)->pad(3)->to_s();
     $sitename = "http://mangahead.com";
     $pref = Text::create($chapter_url);
     if (!$pref->contain('index.php')) {
         $pref = $pref->replace($sitename . '/Manga', $sitename . '/index.php/Manga');
     }
     $finish = false;
     if ($pref->contain('?page=')) {
         $page = (int) $pref->cut_after('?page=')->to_s();
         $pref = $pref->cut_until('?page=');
     } else {
         $page = 1;
     }
     $pages = array();
     while (!$finish) {
         // file_put_contents('/tmp/head', $chapter_url."\n", FILE_APPEND);
         $p = new Page($chapter_url);
         $p->go_line('<blockquote>');
         if ($p->curr_line()->contain('&nbsp;&nbsp;&rsaquo;')) {
             $finish = false;
             $chapter_url = $pref . '/?page=' . ++$page;
         } else {
             $finish = true;
         }
         $srcs = $p->curr_line()->extract_to_array('<img src="', '"');
         foreach ($srcs as $src) {
             $parturl = Text::create($src)->replace('index.php', 'mangas')->replace('?action=thumb', '')->to_s();
             $name = basename($parturl);
             $pages["{$prefix}-{$ifx}-{$name}"] = $sitename . $parturl;
         }
     }
     return $pages;
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:35,代码来源:Mangahead_Crawler.php

示例3: get_images

 public function get_images($chapter_url, $prefix, $infix)
 {
     $ifx = Text::create($infix)->pad(3)->to_s();
     $p = new Page($chapter_url);
     // grab total page
     $p->go_line('id="top_bar"');
     $p->go_line_regex('/of \\d+\\w+/');
     $tot = $p->curr_line()->regex_match('/of (\\d+)/');
     $tot = $tot[1];
     // grab first image
     $p->go_line('id="viewer"');
     $p->next_line(2);
     $src = $p->curr_line()->cut_between('src="', '"');
     $name = basename($src);
     $result = array("{$prefix}-{$ifx}-{$name}" => $src);
     for ($i = 2; $i <= $tot; $i++) {
         $p = new Page(dirname($chapter_url) . '/' . $i . '.html');
         $p->go_line('id="viewer"');
         $p->next_line(2);
         $src = $p->curr_line()->cut_between('src="', '"');
         $name = basename($src);
         $result["{$prefix}-{$ifx}-{$name}"] = $src;
     }
     return $result;
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:25,代码来源:Mangafox_Crawler.php

示例4: crawl_chapter

 public function crawl_chapter($v)
 {
     $ifx = Text::create($v['infix'])->pad(3)->to_s();
     $prefix = $this->prefix;
     $p = new Page($v['url']);
     // grab total page
     $p->go_line('id="top_bar"');
     $p->go_line_regex('/of \\d+\\w+/');
     $tot = $p->curr_line()->regex_match('/of (\\d+)/');
     $tot = $tot[1];
     // grab first image
     $p->go_line('id="viewer"');
     $p->next_line(2);
     $src = $p->curr_line()->cut_between('src="', '"');
     $name = basename($src);
     echo "<a href='{$src}'>{$prefix}-{$ifx}-{$name}</a><br>\n";
     // iterate
     for ($i = 2; $i <= $tot; $i++) {
         $p = new Page(dirname($v['url']) . '/' . $i . '.html');
         $p->go_line('id="viewer"');
         $p->next_line(2);
         $src = $p->curr_line()->cut_between('src="', '"');
         $name = basename($src);
         echo "<a href='{$src}'>{$prefix}-{$ifx}-{$name}</a><br>\n";
     }
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:26,代码来源:mangafox.php

示例5: crawl_chapter

 public function crawl_chapter($v)
 {
     $ifx = Text::create($v['infix'])->pad(3)->to_s();
     $p = new Page($v['url']);
     // ada dua kemungkinan, 1 vol berisi n chap atau 1 chap saja
     $p->go_line_or(array('data[volumechapter]', 'data[pages]'));
     if ($p->curr_line()->contain('data[volumechapter]')) {
         $volchaps = array();
         do {
             $line = $p->curr_line();
             if ($line->contain('</option>')) {
                 $volchaps[$line->cut_between('value="', '"')->to_s()] = $line->cut_between('>', '</option')->to_s();
             }
         } while (!$p->next_line()->contain('</select><br'));
         // traverse per chapter
         foreach ($volchaps as $key2 => $val2) {
             $url2 = dirname($v['url']) . '/' . $key2;
             $this->crawl_page($url2, $ifx);
         }
     } else {
         if ($p->curr_line()->contain('data[pages]')) {
             $this->crawl_page($v['url'], $ifx);
         }
     }
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:25,代码来源:crazytje.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // get POST data
     $input = Input::all();
     // set validation rules
     $rules = array('title' => 'required', 'text' => 'required', 'image' => 'required');
     // validate input
     $validation = Validator::make($input, $rules);
     // if validation fails, return the user to the form w/ validation errors
     if ($validation->fails()) {
         return Redirect::back()->withErrors($validation)->withInput();
     } else {
         // create new Post instance
         $post = Post::create(array('title' => $input['title']));
         // create Text instance w/ text body
         $text = Text::create(array('text' => $input['text']));
         // save new Text and associate w/ new post
         $post->text()->save($text);
         // create the new Image
         $image = Image::create(array('url' => $input['image']));
         // save new Text and associate w/ new post
         $post->image()->save($image);
         if (isset($input['tags'])) {
             foreach ($input['tags'] as $tagId) {
                 $tag = Tag::find($tagId);
                 $post->tags()->save($tag);
             }
         }
         // associate the post with the current user
         $post->author()->associate(Auth::user())->save();
         // redirect to newly created post page
         return Redirect::route('post.show', array($post->id));
     }
 }
开发者ID:shruti222patel,项目名称:laravel-model-demo,代码行数:39,代码来源:PostController.php

示例7: crawl_page

 public function crawl_page($p, $prefix, $ifx)
 {
     $h = new simple_html_dom();
     $h->load($p->content());
     $img = $h->find('#image', 0);
     $src = Text::create($img->src)->cut_before('?');
     $iname = $src->cut_rafter('/');
     return array("{$prefix}-{$ifx}-{$iname}" => $src->to_s());
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:9,代码来源:Mangahere_Crawler.php

示例8: crawl_page

 public function crawl_page($p, $prefix, $ifx, $i)
 {
     $p->go_line('id="manga-page"');
     $img = $p->curr_line()->cut_between('src="', '"')->to_s();
     $iname = urldecode(basename($img));
     $ext = pathinfo($iname, PATHINFO_EXTENSION);
     $iname = Text::create($i)->pad(3) . '.' . $ext;
     return array("{$prefix}-{$ifx}-{$iname}", $img);
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:9,代码来源:Mangastream_Crawler.php

示例9: prepare_dir

 private function prepare_dir($dir, $list_url)
 {
     $dir = $dir ? $dir : $this->default_dir;
     $tags = Text::create($list_url)->cut_after('tags=')->to_s();
     $new_dir = rtrim($dir, '/') . '/' . $tags . '/';
     if (!is_dir($new_dir)) {
         mkdir($new_dir);
     }
     return $new_dir;
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:10,代码来源:Rule34xxx_Downloader.php

示例10: crawl_page

 public function crawl_page($p, $prefix, $ifx)
 {
     $p->go_line('id="imgPage"');
     $img = $p->next_line()->dup()->cut_between('src="', '"')->to_s();
     $iname = urldecode(basename($img));
     // 001_02_22_2012_10_46_59.jpg jadi 001.jpg
     preg_match('/^([^_]+).*\\.(\\w+)$/', $iname, $m);
     // $m[1] no urut, $m[2] extension
     $iname = Text::create($m[1])->pad(3)->to_s() . '.' . $m[2];
     return array("{$prefix}-{$ifx}-{$iname}" => $img);
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:11,代码来源:Mangainn_Crawler.php

示例11: crawl_page

 public function crawl_page($p, $prefix, $ifx, $i)
 {
     $h = new simple_html_dom();
     $h->load($p->content());
     $main_img = $h->find('#mainImg', 0);
     $img = $main_img->src;
     $iname = Text::create($i)->pad(3)->to_s();
     preg_match('/\\.(\\w+)$/', $img, $m);
     $iname = $iname . '.' . $m[1];
     return array("{$prefix}-{$ifx}-{$iname}" => $img);
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:11,代码来源:Mangaeden_Crawler.php

示例12: crawl_page

 public function crawl_page($p, $prefix, $ifx, $i)
 {
     $h = new simple_html_dom();
     $h->load($p->content());
     $img = $h->find('.manga-page', 0);
     $src = $img->src;
     $iname = urldecode(basename($src));
     $ext = pathinfo($iname, PATHINFO_EXTENSION);
     $iname = Text::create($i)->pad(3) . '.' . $ext;
     return array("{$prefix}-{$ifx}-{$iname}", $src);
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:11,代码来源:Mangastreamto_Crawler.php

示例13: crawl_page

 public function crawl_page($p, $ifx, $i)
 {
     $prefix = $this->prefix;
     $p->go_line('id="manga-page"');
     $img = $p->curr_line()->cut_between('src="', '"')->to_s();
     $iname = urldecode(basename($img));
     $ext = pathinfo($iname, PATHINFO_EXTENSION);
     $iname = Text::create($i)->pad(3) . '.' . $ext;
     // 12 karakter aneh
     echo "<li><a href='{$img}'>{$prefix}-{$ifx}-{$iname}</a></li>\n";
     $this->prev_iname = $iname;
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:12,代码来源:mangastream.php

示例14: crawl_page

 public function crawl_page($p, $ifx)
 {
     $prefix = $this->prefix;
     $p->go_line('id="imgPage"');
     $img = $p->next_line()->dup()->cut_between('src="', '"')->to_s();
     $iname = urldecode(basename($img));
     // 001_02_22_2012_10_46_59.jpg jadi 001.jpg
     preg_match('/^([^_]+).*\\.(\\w+)$/', $iname, $m);
     // $m[1] no urut, $m[2] extension
     $iname = Text::create($m[1])->pad(3)->to_s() . '.' . $m[2];
     echo "<a href='{$img}'>{$prefix}-{$ifx}-{$iname}</a><br/>\n";
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:12,代码来源:mangainn.php

示例15: 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;
 }
开发者ID:JerryMaheswara,项目名称:crawler,代码行数:51,代码来源:Rlsbb_Extractor.php


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