Advertisement
FancyKing

利用Jsoup抓取携程旅游网的数据

Apr 3rd, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package step1;
  2. import java.io.File;
  3. import java.io.IOException;
  4. import org.jsoup.Jsoup;
  5. import org.jsoup.nodes.Document;
  6.  
  7. public class Task {
  8.     /**
  9.      * @param filePath  文件路径:backups/www.ctrip.com.txt/
  10.      * @return
  11.      * @throws IOException
  12.      */
  13.     public Document getHtml1(String filePath) throws IOException{
  14.         /**********   Begin   **********/
  15.         Document document = Jsoup.parse( new File( "./backups/www.ctrip.com.txt" ) , "utf-8" );
  16.        
  17.         return document;
  18.         /**********   End   **********/
  19.     }
  20.  
  21.     /**
  22.      *
  23.      * @param filePath  文件路径:backups/hotels.ctrip.com_domestic-city-hotel.txt/
  24.      * @return
  25.      * @throws IOException
  26.      */
  27.     public Document getHtml2(String filePath) throws IOException{
  28.         /**********   Begin   **********/
  29.         Document document = Jsoup.parse( new File( "./backups/hotels.ctrip.com_domestic-city-hotel.txt" ) , "utf-8" );
  30.  
  31.         return document;
  32.         /**********   End   **********/
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement