Crawlers _ movie ftp download address

Source: Internet
Author: User
: This article mainly introduces crawlers-movie ftp. if you are interested in PHP tutorials, refer to it. Site: http://www.dy2018.com/

Database: mysql account: root Password: 123456

Create table statement: create table dy2008_url (id int (9) not null AUTO_INCREMENT, url varchar (2000) not null, status tinyint (2) not null, primary key (id ));

Code:

 Array ('method' => 'post', 'header' => 'Content-type: application/x-www-form-urlencoded '. 'content-Length :'. strlen ($ data ). '"', 'content' => $ data); $ context = stream_context_create ($ opts); $ content = file_get_contents ($ url, false, $ context ); return $ content;} // dy2018 capture the main flow function run_dy2018 () {global $ crawlers_pid; global $ finish_count; $ crawl_urls = array (" http://www.dy2018.com/html/tv/hytv/ "," http://www.dy2018.com/html/tv/hepai/ "," http://www.dy2018.com/html/tv/gangtai/ "," http://www.dy2018.com/html/tv/oumeitv/ "," http://www.dy2018.com/html/tv/rihantv/ "," http://www.dy2018.com/html/tv/tvzz/ "," http://www.dy2018.com/0/ "," http://www.dy2018.com/1/ "," http://www.dy2018.com/2/ "," http://www.dy2018.com/3/ "," http://www.dy2018.com/4/ "," http://www.dy2018.com/5/ "," http://www.dy2018.com/6/ "," http://www.dy2018.com/7/ "," http://www.dy2018.com/8/ "," http://www.dy2018.com/9/ "," http://www.dy2018.com/10/ "," http://www.dy2018.com/11/ "," http://www.dy2018.com/12/ "," http://www.dy2018.com/13/ "," http://www.dy2018.com/14/ "," http://www.dy2018.com/15/ "," http://www.dy2018.com/16/ "," http://www.dy2018.com/17/ "," http://www.dy2018.com/18/ "," http://www.dy2018.com/19/ "," http://www.dy2018.com/20/ "); $ I = 0; while ($ I <count ($ crawl_urls) {$ pid = pcntl_fork (); if ($ pid =-1) {echo "system error. check it now! "; Exit ();} else if ($ pid> 0) {$ crawlers_pid [$ I] = $ pid;} else {$ url = $ crawl_urls [$ I]; $ con = mysql_connect ("localhost", "root", "123456"); if (! $ Con) {die ('Count not connect :'. mysql_error ();} mysql_select_db ("mysql", $ con); crawl_process ($ url); $ finish_count ++;} $ I ++ ;} // pcntl_waitpid may cause signal listening failure while (true) {if ($ finish_count = count ($ crawler s_pid) {echo "---------- crawl task finish ----------"; mysql_close (); exit () ;}sleep (1) ;}// link from the menu to all download page links under the capture process function crawler process ($ url) {echo "start handle url :". $ url; $ page_idx = 1; $ valid_tag = true; $ Info_url_pattern = '/\/I \/\ d).html/'; $ ftp_url_pattern = '/ftp :\/\/.*?. (Swf | avi | flv | mpg | rm | mov | wav | asf | 3gp | mkv | rmvb)/I '; // ^ $ the two symbols do not work while ($ valid_tag) {$ page_url = get_page_index_url ($ url, $ page_idx); printf ("start crawl url :". $ page_url. "\ n"); $ page_content = get_page_content ($ page_url); $ valid_tag = is_valid_page ($ page_content); if ($ valid_tag) {$ matches_urls = array (); preg_match_all ($ info_url_pattern, $ page_content, $ matches_urls); $ page_content = mb_convert_encoding ($ page_content, "UTF-8", "GBK"); for ($ I = 0; $ I
 
  
1) {$ idx_url = $idx_url.'index_'.$idx.'.html ';} return $ idx_url;} // Determine whether the link is valid based on the page content. function is_valid_page ($ content) {return $ content? True: false;} run_dy2018 (); mysql_close ();?>
 

Result:

The above introduces the crawler movie ftp, including some content, and hopes to help friends who are interested in PHP tutorials.

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.