Youku TV series Crawler Code implementation one: Download parse video site page (2)

Source: Internet
Author: User

1. Create a new TV drama reptile Entrance class Startdsjcount. If you need art or film later, you can also imitate the new art or movie Crawler entrance class.

Package Com.dajiangtai.djt_spider.start;

Import Com.dajiangtai.djt_spider.entity.Page;
Import Com.dajiangtai.djt_spider.service.IDownLoadService;
Import Com.dajiangtai.djt_spider.service.impl.HttpClientDownLoadService;

/**
* TV series Reptile Entrance class
* @author Administrator
* 1. Define the page download interface in Startdsjcount Downloadservice

2. It needs to be get/set, so that after Startdsjcount instantiation, you can set the property downloadservice, which needs to be instantiated, so the interface is instantiated using Set mode.

3. Add Public Page downloadpage (String url) method, call interface This.downLoadService.download (URL) method

Test in the 4.main method.
*/
public class Startdsjcount {

Page Download interface
Private Idownloadservice Downloadservice;

public static void Main (string[] args) {
Startdsjcount DSJ = new Startdsjcount ();
Dsj.setdownloadservice (New Httpclientdownloadservice ());
String url = "Http://list.youku.com/show/id_z9cd2277647d311e5b692.html?spm=a2h0j.8191423.sMain.5~5~A!2.iCUyO9";
Download page
Page page = dsj.downloadpage (URL);
System.out.println (Page.getcontent ());

}

Download Page method
Public Page downloadpage (String URL) {
return this.downLoadService.download (URL);
}

Public Idownloadservice Getdownloadservice () {
return downloadservice;
}

public void Setdownloadservice (Idownloadservice downloadservice) {
This.downloadservice = Downloadservice;
}

}

Test results:

2. Define the parsing interface Iprocessservice. Here is the example of Youku, different video sites have different page formats, so the parsing is different. Therefore, a parsing interface needs to be implemented.

Package com.dajiangtai.djt_spider.service;

Import Com.dajiangtai.djt_spider.entity.Page;

/**
* Page Parsing interface
* @author Administrator
*
*/
Public interface Iprocessservice {

public void Process (Page page);
}

Youku TV series Crawler Code implementation one: Download parse video site page (2)

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.