Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7190721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:34:35+00:00 2026-05-28T19:34:35+00:00

I want to use java to retrieve text from a website. I can easily

  • 0

I want to use java to retrieve text from a website. I can easily get the source by doing: (Thank you random internet person who posted this somewhere else)

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;

    public class WebCrawler{
        public static void main(String[] args) {
            try {
                URL google = new URL("http://stackoverflow.com");
                URLConnection yc = google.openConnection();
                BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
                String inputLine;
                while ((inputLine = in.readLine()) != null) {
                    System.out.println(inputLine);

                }
                in.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

However this leaves me with the problem of some sites returning 403s. Is there a way of getting around this?

Very simply I was hoping to use java to create a simple bot that would scan a forum thread and automatically respond based of user queries. Am I able to do this in java? or do I need to look at it from the perspective of another language/ data retrieval method?

Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:34:36+00:00Added an answer on May 28, 2026 at 7:34 pm

    Yes, this can be done in Java. In theory, anything a web browser can do, Java can do – since, in the very worst case, you could write a web browser in Java.

    A 403 is a “forbidden” response. You may need to set a particular User-Agent header, or the site might require HTTP basic authentication. Or perhaps it’s rate-limiting you and you need to see about obeying their robots.txt rules…

    Java is certainly not (in my opinion) the easiest language in which to write this type of code, but you’re on a decent track here.

    As for your “not source” in the title – the source of a web page is its text. If you download the page, you’re going to get HTML; it’s up to you to parse out what you need and discard the dross.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i use java reflections to get methods used in a class.I also want to
I found this open-source library that I want to use in my Java application.
Recently, I start to use ojAlgo library. You can get more information from http://ojalgo.org/index.html
I want to use java.net.url to crawl some websites and retrieve some data. I
I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here's the
I want to use the java.util.Preferences API but I don't want my program to
I don't want to use any Java code, I just want to use <jsp:include>
I want to use curl in java. Is curl built-in with Java or I
I want to use pooled connections with Java (because it is costly to create
I want to use JOGL (for Clojure, not Java). There seems to be quite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.