JSP "capture" Web Page code program (embed others' web pages in your own web pages)

Source: Internet
Author: User
<% @ Page contenttype = "text/html; charset = gb2312" %>
<%

String scurrentline;

String stotalstring;

Scurrentline = "";

Stotalstring = "";

Java. Io. inputstream l_urlstream;

Java.net. url l_url = new java.net. URL ("http://www.163.net /");

Java.net. httpurlconnection l_connection = (java.net. httpurlconnection) l_url.openconnection ();

Rochelle connection.connect ();

Rochelle urlstream = Rochelle 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 );

%>

Postscript

AlthoughCodeIt is relatively simple, but I think that, based on this, we can implement the "web crawler" function, for example, find the href connection from the page, then get the connection, and then "catch ", do not stop (of course, you can limit the number of layers). In this way, you can implement the "Webpage Search" function.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.