README.md

December 5, 2022 ยท View on GitHub

Downloading Web Page HTML Example

Description

This code demonstrates how to download the HTML source code from a specified web page and output it to the screen. Can be used to retrieve tags, or words, or peanut butter from web pages. Enjoy.

More Info

Blindness?

Submitted On
ByC.V.
LevelIntermediate
User Rating5.0 (10 globes from 2 users)
CompatibilityJava (JDK 1.1), Java (JDK 1.2)
CategoryInternet/ Browsers/ HTML
WorldJava
Archive File

Source Code

import java.net.*;
import java.io.*;
public class URL1
{
  public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.coryvia.net");
    InputStream html = url.openStream();
    int c = 0;
    String a = "";
    while(c != -1) {
      a = "";
      c = html.read();
      if(c == (char)60) {
        while(c != (char)62) {
          a = a + (char)c;
          c = html.read();
        }
      }
      if(a == "") {}
      else
        System.out.println(a + ">");
    }
  }
}