0

I'm trying to get data from an webpage for an program written in Java I'm working on but for some reason i can't seem to figure out how to do it the right way.

This is the piece of HTML:

enter image description here

And all I need to get the word "Crush".

What is the best way to do this in Java?

Piet Jetse
  • 388
  • 1
  • 5
  • 16
  • 1
    You have `java` as a tag, `html-parsing` as another, and mention `javascript`... all I see is HTML. What language are you trying to do this with? – Eric Hotinger May 30 '14 at 10:53
  • I need to get the data using Java. – Piet Jetse May 30 '14 at 10:54
  • Haha yeah he means how to parse html from a webpage in JAVA, but to much people are editing – Sander Visser May 30 '14 at 10:54
  • I've used jsoup for this before - but really just choose a library of your liking. SO isn't the best place to recommend tools. – Eric Hotinger May 30 '14 at 10:55
  • @PietJetse what have you tried so far? Have you Googled about how you can parse `HTML` in `Java`? – Sufian May 30 '14 at 10:58
  • I got the code as an String and i tried to manipulate the string using methods like StartsWith, contains and replace. – Piet Jetse May 30 '14 at 10:59
  • You can use `regex` to find the required text. – MjZac May 30 '14 at 11:03
  • @PietJetse why are you reinventing the wheel? Please do a Google search before posting a question. – Sufian May 30 '14 at 11:10
  • Does the webpage have a unique div/span for the data you're trying to get at? If the span is not unique and/or changes frequently then there's not much point trying to parse it – Kyte May 30 '14 at 13:39

1 Answers1

0

There are libraries that will do this for you.

You could always use a combination of the native Java libraries to accomplish this. You can read the HTML from an input stream one line at a time and do a string.contains("Crush")

Kyte
  • 834
  • 2
  • 12
  • 27