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

  • Home
  • SEARCH
  • 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 8299685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:14:52+00:00 2026-06-08T16:14:52+00:00

I am trying to screen- scrape a html page so I can extract desired

  • 0

I am trying to screen-scrape a html page so I can extract desired valuable data from it and into a text file. So far it’s going well until I came across this within the html page:

<td> <b>In inventory</b>: 0.3 &#107;&#103;<br /><b>Equipped</b>: -4.5&#160;kg

The above line in the html code for the page often varies. So it need to figure about a way to scan the line (regardless of what it contains) for the weight (in this case would be 0.3 and -4.5) and store this data into 2 seperate doubles as of such:

double inventoryWeight = 0.3
double equippedWeight = -4.5

I would like this to be done using pure java; if need be, do not hesitate to notify me of any third-party programs which can be executed within my java application to achieve this (but please vividly explain if so).

Thank you a bunch!

  • 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-06-08T16:14:58+00:00Added an answer on June 8, 2026 at 4:14 pm

    RegEx is usually a good solution for scraping text. Parentheses denote “capturing groups”, which are stored and can then be accessed using Matcher.group(). [-.\d]+ matches anything consisting of one or more digits (0-9), periods, and hyphens. .* matches anything (but sometimes not newline characters). Here it’s just used to essentially “throw away” everything you don’t care about.

    import java.util.regex.*;
    
    public class Foo {
        public static void main(String[] args) {
            String regex = ".*inventory<\\/b>: ([-.\\d]+).*Equipped<\\/b>: ([-.\\d]+).*";
            String text = "<td> <b>In inventory</b>: 0.3 &#107;&#103;<br /><b>Equipped</b>: -4.5&#160;kg";
    
            // Look for a match
            Pattern pattern = Pattern.compile(regex);
            Matcher matcher = pattern.matcher(text);
    
            // Get the matched text
            if (matcher.matches()) {
                String inventoryWeight = matcher.group(1);
                String equippedWeight = matcher.group(2);
    
                System.out.println("Inventory weight: " + inventoryWeight);
                System.out.println("Equipped weight: " + equippedWeight);
            } else {
                System.out.println("No match!");
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to screen scrape values from a website. # get the raw
i'm trying to get the html of a page using this screen scraping in
I am currently trying to do a screen scrape using the following code: HttpWebRequest
I'm trying to build a screen like this: How can I split my cell
I'm trying to open the On Screen Keyboard from within a web application on
I am trying to screen scrape using C#.It works for few times,after which i
I'm trying to build an android app that will log into a website, scrape
Im trying to save a screen from my app with th use of a
OK, this is driving me nuts. I'm trying to screen-scrape the following bit of
I want to screen scrape the image from a GLUT window that has been

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.