Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package step1;
- import java.io.File;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import org.jsoup.safety.Whitelist;
- public class Task {
- //通过filePath文件路径获取Docment对象
- public Document getDoc(String filePath) throws IOException{
- /********** Begin **********/
- File input = new File(filePath);
- Document document =Jsoup.parse(input,"UTF-8","http://www.ctrip.com/");
- return document;
- /********** End **********/
- }
- /**
- * 获取清理后的信息
- * @param doc
- * @return
- */
- public List<String> cleanHTML(Document doc){
- /********** Begin **********/
- List<String> tmp=new ArrayList<>();
- String tmpb =Jsoup.clean(doc.toString() ,Whitelist.basic());
- String tmpc =Jsoup.clean(doc.toString() ,Whitelist.simpleText());
- tmp.add(tmpb);
- tmp.add(tmpc);
- return tmp;
- /********** End **********/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment