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 4004530
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:17:04+00:00 2026-05-20T08:17:04+00:00

Using Java, how can I extract all the links from a given web page?

  • 0

Using Java, how can I extract all the links from a given web page?

  • 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-20T08:17:05+00:00Added an answer on May 20, 2026 at 8:17 am

    download java file as plain text/html pass it through Jsoup or html cleaner both are similar and can be used to parse even malformed html 4.0 syntax and then you can use the popular HTML DOM parsing methods like getElementsByName(“a”) or in jsoup its even cool you can simply use

    File input = new File("/tmp/input.html");
     Document doc = Jsoup.parse(input, "UTF-8", "http://example.com/");
    
    Elements links = doc.select("a[href]"); // a with href
    Elements pngs = doc.select("img[src$=.png]");
    // img with src ending .png
    
    Element masthead = doc.select("div.masthead").first();
    

    and find all links and then get the detials using

    String linkhref=links.attr("href");
    

    Taken from http://jsoup.org/cookbook/extracting-data/selector-syntax

    The selectors have same syntax as jQuery if you know jQuery function chaining then you will certainly love it.

    EDIT: In case you want more tutorials, you can try out this one made by mkyong.

    http://www.mkyong.com/java/jsoup-html-parser-hello-world-examples/

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

Sidebar

Related Questions

I'm trying to extract two blocks of code from a text file using Java
I am developing a web browser in java. For parsing and rendering I am
Say I have a Java String which has xml data like so: String content
I am working with files (reading, writing and copying) in my Java application, java.io.File
I created a small application to read some files from the disk and zip
I'm working on a project and I need to do a lot of screen
My intent is to create a library/API for small scale distributed multi-user game /simulation.
I'm going crazy about my actual project... I've got a device which is sending
I need to find an algorithm which determines a relationship between a square and
int BUFFER_SIZE = 4096; byte[] buffer = new byte[BUFFER_SIZE]; InputStream input = new GZIPInputStream(new

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.