Eleven of the JavaJSP Learning Series (Simple "Glance Website" code)

zhaozj2021-02-16  51

First, in the foreword, from a website, see a "scratch" code, feel a bit, but there is no source code, so I want to write one, in fact, the code is simple. Second, the code <% @ page contentType = "text / html; charset = gb2312"%> <% String sCurrentLine; String sTotalString; sCurrentLine = ""; sTotalString = ""; java.io.InputStream l_urlStream; java.net.URL l_url = new ( "http://www.163.net/") java.net.URL; 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;} Out.println (STOTALSTRING);%> Third, after the code is simple, I think it can realize the "network reptile" function, such as looking for href connections from the page, then get that connection, then "Grab", do not stop (of course, the number of layers can be limited) so that the "web search" function can be implemented.

转载请注明原文地址:https://www.9cbs.com/read-19785.html

New Post(0)