Task :
Display a list of 10 cities with the current ambient temperature. List in alphabetical order.
Separately display a list of cities where it is snowing now (either rain, or overcast, or sunny).
Also to keep on screen how long the program was running.
My decision course:
Chose a site: http://www.travel.ru/weather/russia/
Connected library: jsoup
Does not work :
Pull out the name of the city from the tr tag and put it into a variable.
Pull out the weather forecast and put it into a variable.
In general, Houston, we have problems.
My code is:
package devjatnadcat; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; public class Devjatnadcat1{ public static void main(String[] args) throws IOException { List<Article> articleList = new ArrayList<>(); Document doc = Jsoup.connect("http://travel.ru/weather/russia/").get(); Elements trElements = doc.getElementsByAttributeValue("class", "b-table_row b-forecast"); trElements.forEach(trElement ->{ Element }); } } class Article{ private String url; private String name; public Article(String url,String name){ this.url=url; this.name=name; } public String getUrl(){ return url; } public void setUrl(){ this.url=url; } public String getName(){ return name; } public void setName(){ this.name=name; } }
trElement ->{ Element }: D - Sublihim