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)