登录 注册
当前位置:主页 > 资源下载 > 9 > 下载网页使用htmlparser

下载网页使用htmlparser

  • 更新:2024-06-25 14:35:44
  • 大小:18KB
  • 推荐:★★★★★
  • 来源:网友上传分享
  • 类别:Java - 后端
  • 格式:DOCX

资源介绍

import org.htmlparser.Node; import org.htmlparser.NodeFilter; import org.htmlparser.Parser; import org.htmlparser.filters.TagNameFilter; import org.htmlparser.tags.TableTag; import org.htmlparser.util.NodeList; public class TestYahoo { public static void testHtml() { try { String sCurrentLine; String sTotalString; sCurrentLine = ""; sTotalString = ""; java.io.InputStream l_urlStream; java.net.URL l_url = new java.net.URL( "http://sports.sina.com.cn/iframe/nba/live/"); java.net.HttpURLConnection l_connection = (java.net.HttpURLConnection) l_url .openConnection(); l_connection.connect(); l_urlStream = l_connection.getInputStream(); java.io.BufferedReader l_reader = new java.io.BufferedReader( new java.io.InputStreamReader(l_urlStream)); while ((sCurrentLine = l_reader.readLine()) != null) { sTotalString += sCurrentLine; }