I am working on coding a program that will go and get the price of a person from a table on a website. The code gets the last name and looks for a table for that name before returning the price (another column) whenever I run it. I get java.net.SocketTimeoutException: timeout
This is the code I use to request a website
public String price(String lastName) throws IOException
{
Document doc = Jsoup.connect(url).get();
Elements rows = doc.getElementsByTag("tr");;
for(Element row : rows)
{
Elements columns = row.getElementsByTag("td");
String lastName = columns.get(0).text();
String price = columns.get(2).text();
if(lastName.equalsIgnoreCase(name))
{
return price;
}
}
return null;
}
source
share