Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

Web Page Text Search - Java Code Bank


Web Page Text Search
This is how to search for a string on a web page.
                package shoutboxcheck;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import static java.lang.System.*;
/**
 *
 * @author Kenneth
 */
public class Main {

    public static void main(String[] args) throws MalformedURLException, IOException, InterruptedException {
        // Assign variables
        URL url = null;
        String line = null;
        String page = null;
        LineNumberReader lnreader = null;
        BufferedReader reader = null;
        String user = "kenneth_nap";
        url = new URL("http://www.hellboundhackers.org/shoutbox/shoutbox_archive.php");
        HttpURLConnection Conn = (HttpURLConnection)url.openConnection();
        
        // Connect to the url.
        Conn.connect();

                reader = new BufferedReader(new InputStreamReader(url.openStream())); // Read input stream.
                lnreader = new LineNumberReader(reader); // Read line number.
                
                while ((line = reader.readLine()) != null)
                {
                page += line; // Add each line to page.
                } // end while ((line = reader.readLine()) != null)

                    if(page.contains(user)) // If user is on page.
                    {
                        out.println(user + " is on page.");
                    } // end If(page.contains(user))
                    else // If user is not on page.
                    {
                        out.println(user + " is not on page.");
                    } // end else

                    System.exit(0); // exit
    } // end method main
} // end Class Main
            
Comments
Sorry but there are no comments to display