I would like to take some data from www.groupon.pl website. To do this I used code below:
String currentUrl = "https://www.groupon.pl/browse/radom";
URL urlObj = new URL(currentUrl);
HttpURLConnection urlConnection = (HttpURLConnection) urlObj.openConnection();
urlConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0");
urlConnection.connect();
final HtmlCleaner cleaner = new HtmlCleaner();
final TagNode tagNodeRoot = cleaner.clean(urlConnection.getInputStream());
The problem is that after the last line:
final TagNode tagNodeRoot = cleaner.clean(urlConnection.getInputStream());
The program doesn't want go further. I think that maybe the problem is with:
urlConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0");
Or maybe I use some and old API which is not supported any more? Could you tell me what is wrong? Thank you.
Aucun commentaire:
Enregistrer un commentaire