1

I'm trying to parse a web page with Jsoup library. But since its adress is like host and port together (http://host:port) (Stackoverflow does not allow to write the exact thing) Jsoup throws an exception and does not parse the page.

Here is the page adress:

And here is the Exception log:

org.jsoup.HttpStatusException: HTTP error fetching URL. Status=-1, URL=http://sunucu2.radyolarburada.com:5000/
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:435)
    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410)
    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153)
    at Tester.getSong(Tester.java:136)
    at Tester.main(Tester.java:150)
7
  • Stackoverflow does not allow me to right the link thats why stacktrace is kind of different Commented Jul 26, 2013 at 20:55
  • Paste it on different lines, I'll edit for you and make them a link. You can do like: "http colon // www dot example dot org colon 8080". Commented Jul 26, 2013 at 20:56
  • I edited it now. Did I edit it right? Commented Jul 26, 2013 at 21:08
  • What command did you use to fetch/get the page? Commented Jul 26, 2013 at 21:20
  • @acdcjunior try { doc = Jsoup.connect("sunucu2.radyolarburada.com:5000/").get(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Commented Jul 26, 2013 at 21:44

1 Answer 1

2

Include the userAgent in your Jsoup request

Document document = Jsoup.connect("http://sunucu2.radyolarburada.com:5000/")
                            .userAgent("Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36")
                            .timeout(0).followRedirects(true).execute().parse();
        System.out.println(document.html());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.