I have a web pages scraper that grabs text using a tag from html "tr"
I can retrieve the data sucessfully, but I want to add it to either an array or to a string, because I need to select specific elements from it.
Currently the follwoing:
public HtmlParser(Properties configuration) throws IOException {
String url = configuration.getProperty("url");
Document doc = Jsoup.connect(url).get();
// this.doc = doc;
this.dataString = new String();
Elements tableRows = doc.getElementsByTag("tr");
for (Element tr : tableRows){
dataString.add(tr.text());
}
which will return the text I need, along the lines of:
[Flights on time 93%, Within 1 hour 99%, FLIGHT FROM TO DEPART ARRIVE STATUS, FR 9083 Bournemouth Alicante 10:10 13:35 Landed 19:00, FR 1902 Krakow Dublin 10:45 12:55 Estimated Arrival 23:05, ATC DELAY, FR 1402 Shannon Tenerife Sth 11:15 15:15 Estimated Arrival 19:53, OPERATING FROM SHANNON AIRPORT. PASSENGERS TO BE COACHED TO SHANNON AIRPORT.,
I want to return the above text into an array or string whichever applicable.
with the above text, I am getting a compile error saying
The method add(String) is undefined for the type String
when I try to add the data from each iteraton of the for loop to the string I'm getting the compile error above, and I've tried using .add and .append but it doesn't work. How do I fix this?
Also, my next step is to split the string by the operator "," and possibly a space.
If I split the text does it need to be into an array, or will a string will do? if so, how do I do it?
Im reasonably new to java and I'm learning as I go here, so any help anyone can give me would be greatly appreciated.
I'm also then looking to select any of the involved strings based on certain criteria like a keyword. How does one do this?