CodeIgniter implements the method of fetching pictures from Web sites and automatically downloading them into folders, CodeIgniter crawl _php Tutorials

Source: Internet
Author: User
Tags codeigniter

CodeIgniter implements the method of fetching pictures from Web sites and automatically downloading them into folders, CodeIgniter crawl


The examples in this article describe the way CodeIgniter implements fetching pictures from a Web site and automatically downloading them to a folder. Share to everyone for your reference. Specific as follows:

Because a site look at the picture compared to the pit father, to page by page pages .... So.... That's what I wrote.

(I am a product is not a programmer) running speed is simply unbearable, and often mistakes occur, so I hope you help improve (PHP).

Of course also welcome to see the version of Python,golang ~ ~ ^_^

1. Controllers:

$this->load->helper (' Date '); $this->load->helper (' phpquery ');//I've put the phpquery file in the helper.

2. View:

This is just for quick product, so write the code directly in the view, ignore the variable name ...

<?php$imageslist = Phpquery::newdocumentfile (' http://g.e-hentai.org/g/xxxxx/xxxxxxx/');//Home $PN = 1;//pages $ps = $ Imageslist->find ('. PTT TD a ');//page navigation//From page navigation start to get page content foreach ($ps as $p) {  echo '. $pn + +. ' Page: attr ("href"). ' " />
'; $imagesnow = Phpquery::newdocumentfile (PQ ($p)->attr ("href")); Single page content $images = $imagesnow->find (' #gdt a '),//Grab picture Page List foreach ($images as $image) { echo ' attr (" href "). '" />
'; $imagebigs = Phpquery::newdocumentfile (PQ ($image, $imagesnow)->attr ("href")); Get the single picture page address echo ' Find (' #i3 img ')->attr (' src '). >
';//Output Picture Ob_start (); ReadFile ($imagebigs->find (' #i3 img ')->attr (' src ')); $img = Ob_get_contents (); Ob_end_clean (); $filename = ' img/'. Now (). JPG '; $f =fopen ($filename, ' a '); Fwrite ($f, $img); Fclose ($f); }? >

I hope this article is helpful to everyone based on CodeIgniter PHP program design.

http://www.bkjia.com/PHPjc/1018527.html www.bkjia.com true http://www.bkjia.com/PHPjc/1018527.html techarticle CodeIgniter implementation of the method from the site to grab pictures and automatically download to the folder, CodeIgniter crawl This example tells the CodeIgniter implementation from the site to grab pictures and automatically download to the folder ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.