1

By using jsoup I am trying to get text from a link. But it always give me the end of the file error: java.io.EOFException in android. I have also tried jericho html parser but both of them are sending same error. Here is my code:

private class JsoupAsyncTask extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(Void... params) {
            try {
                doc = Jsoup.connect("http://www.azlyrics.com/lyrics/adele/hello.html").get();
                htmlText = doc.body().text();
                Log.e("html text", "working");
            } catch (IOException e) {
                Log.e("html text", e.toString());
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            lyricsText.setText(htmlText);
        }
    }

I dont know why the error is happening. Please help me if anyone have any idea about it.

1
  • Can you give the actual stack trace that's being produced? Commented Dec 20, 2015 at 9:59

1 Answer 1

2

Add user agent:

Document doc = Jsoup.connect("http://www.azlyrics.com/lyrics/adele/hello.html")
.userAgent("Mozilla").get();
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.