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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:14:20+00:00 2026-05-14T05:14:20+00:00

I am now trying to implement a simple HTML webpage scraper using Java.Now I

  • 0

I am now trying to implement a simple HTML webpage scraper using Java.Now I have a small problem.
Suppose I have the following HTML fragment.

<div id="sr-h-left" class="sr-comp">
    <a class="link-gray-underline" id="compare_header"  rel="nofollow" href="javascript:i18nCompareProd('/serv/main/buyer/ProductCompare.jsp?nxtg=41980a1c051f-0942A6ADCF43B802');">
        <span style="cursor: pointer;" class="sr-h-o">Compare</span>
    </a>
</div>
<div id="sr-h-right" class="sr-summary">
    <div id="sr-num-results">
        <div class="sr-h-o-r">Showing 1 - 30 of 1,439 matches, 

The data I am interested is the integer 1.439 shown at the bottom.I am just wondering how can I get that integer out of the HTML.
I am now considering using a regular expression,and then use the java.util.Pattern to help get the data out,but still not very clear about the process.
I would be grateful if you guys could give me some hint or idea on this data scraping.
Thanks a lot.

  • 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-14T05:14:20+00:00Added an answer on May 14, 2026 at 5:14 am

    Regular expressions are probably the best way to do it. Something like:

    Pattern p = Pattern.compile("Showing [0-9,]+ - [0-9,]+ of ([0-9,]+) matches");
    Matcher m = p.matches(scrapedHTML);
    if(m.matches()) {
        int num = Integer.parseInt(m.group(1).replaceAll(",", ""));
        // num == 1439
    }
    

    I’m not sure what you meant by understanding the “process”, but here’s what that code does: p is a regular expression pattern that matches the “Showing…” line. m is the result of applying that pattern to the scraped HTML. If m.matches() is true it means the pattern matched the HTML, and m.group(1) will be the first regular expression group (expression in parentheses) in the pattern, which was ([0-9,]+), which matches a string of digits and commas, so it’ll be “1,459”. The replaceAll() call turns that into “1459”, and Integer.parseInt() turns that into the integer 1459

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

Sidebar

Ask A Question

Stats

  • Questions 428k
  • Answers 428k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Exist property accepts a value of how long to… May 15, 2026 at 1:21 pm
  • Editorial Team
    Editorial Team added an answer Join essentially says to combine two tables and treat it… May 15, 2026 at 1:21 pm
  • Editorial Team
    Editorial Team added an answer Here's a working version: import urllib2, cookielib import ClientForm from… May 15, 2026 at 1:21 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.