Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:26:35+00:00 2026-06-04T04:26:35+00:00

I have a problem with parsing html with JSoup The code is from a

  • 0

I have a problem with parsing html with JSoup

The code is from a tutorial found here, but it just wont work it keeps trowing error

Here is the code

static final String BLOG_URL = "http://xjaphx.wordpress.com/";

@Override
public void onCreate(Bundle savedInstanceState) {
    // set layout view
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);



    // process
   try {
        ((TextView)findViewById(R.id.text)).setText(getBlogStats());
        Log.i("complete","completed");
    } catch (Exception ex) {
        ((TextView)findViewById(R.id.text)).setText("Error");
         Log.i("error","error", ex);
    }
}



protected String getBlogStats() throws Exception {
    String result = "";
    // get html document structure
    Document document = Jsoup.connect(BLOG_URL).get();
    // selector query
    Elements nodeBlogStats = document.select("div#blog-stats ul li");
    // check results
    if(nodeBlogStats.size() > 0) {
        // get value
        result = nodeBlogStats.get(0).text();
    }

    // return
    return result;
}
    }

I have also tryed to log error but i dont understand anything from the output

05-18 15:18:19.706: V/Performance(28824): >>AppBindData{appInfo=ApplicationInfo{40d7a918 com.android.test}} handleBindApplication
05-18 15:18:19.746: V/Performance(28824): >>android.app.ActivityThread@40d792d0 newApplication
05-18 15:18:19.746: V/Performance(28824): <<android.app.ActivityThread@40d792d0 newApplication, 0ms
05-18 15:18:19.746: V/Performance(28824): >>android.app.Application@40d82028 onCreate
05-18 15:18:19.746: V/Performance(28824): <<android.app.Application@40d82028 onCreate, 0ms
05-18 15:18:19.746: V/Performance(28824): <<AppBindData{appInfo=ApplicationInfo{40d7a918 com.android.test}} handleBindApplication, 35ms
05-18 15:18:19.746: V/Performance(28824): >>com.android.test.testActivity@40d83970 onCreate
05-18 15:18:19.876: I/error(28824): error
05-18 15:18:19.876: I/error(28824): android.os.NetworkOnMainThreadException
05-18 15:18:19.876: I/error(28824):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1178)
05-18 15:18:19.876: I/error(28824):     at java.net.InetAddress.lookupHostByName(InetAddress.java:394)
05-18 15:18:19.876: I/error(28824):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:245)
05-18 15:18:19.876: I/error(28824):     at java.net.InetAddress.getAllByName(InetAddress.java:220)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:71)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:351)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:86)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:308)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpEngine.connect(HttpEngine.java:303)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:282)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:232)
05-18 15:18:19.876: I/error(28824):     at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
05-18 15:18:19.876: I/error(28824):     at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:404)
05-18 15:18:19.876: I/error(28824):     at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:391)
05-18 15:18:19.876: I/error(28824):     at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:157)
05-18 15:18:19.876: I/error(28824):     at org.jsoup.helper.HttpConnection.get(HttpConnection.java:146)
05-18 15:18:19.876: I/error(28824):     at com.android.test.testActivity.getBlogStats(testActivity.java:42)
05-18 15:18:19.876: I/error(28824):     at com.android.test.testActivity.onCreate(testActivity.java:29)
05-18 15:18:19.876: I/error(28824):     at android.app.Activity.performCreate(Activity.java:4531)
05-18 15:18:19.876: I/error(28824):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
05-18 15:18:19.876: I/error(28824):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150)
05-18 15:18:19.876: I/error(28824):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
05-18 15:18:19.876: I/error(28824):     at android.app.ActivityThread.access$600(ActivityThread.java:139)
05-18 15:18:19.876: I/error(28824):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
05-18 15:18:19.876: I/error(28824):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-18 15:18:19.876: I/error(28824):     at android.os.Looper.loop(Looper.java:154)
05-18 15:18:19.876: I/error(28824):     at android.app.ActivityThread.main(ActivityThread.java:4944)
05-18 15:18:19.876: I/error(28824):     at java.lang.reflect.Method.invokeNative(Native Method)
05-18 15:18:19.876: I/error(28824):     at java.lang.reflect.Method.invoke(Method.java:511)
05-18 15:18:19.876: I/error(28824):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-18 15:18:19.876: I/error(28824):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-18 15:18:19.876: I/error(28824):     at dalvik.system.NativeStart.main(Native Method)
05-18 15:18:19.876: V/Performance(28824): <<com.android.test.testActivity@40d83970 onCreate, 128ms
05-18 15:18:19.876: V/Performance(28824): >>com.android.test.testActivity@40d83970 onStart
05-18 15:18:19.876: V/Performance(28824): <<com.android.test.testActivity@40d83970 onStart, 0ms
05-18 15:18:19.876: V/Performance(28824): >>com.android.test.testActivity@40d83970 onPostCreate
05-18 15:18:19.876: V/Performance(28824): <<com.android.test.testActivity@40d83970 onPostCreate, 1ms
05-18 15:18:19.876: V/Performance(28824): >>com.android.test.testActivity@40d83970 onResume
05-18 15:18:19.876: V/Performance(28824): <<com.android.test.testActivity@40d83970 onResume, 0ms
05-18 15:18:19.936: D/libEGL(28824): loaded /system/lib/egl/libGLES_android.so
05-18 15:18:19.936: D/libEGL(28824): loaded /system/lib/egl/libEGL_adreno200.so
05-18 15:18:19.946: D/libEGL(28824): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
05-18 15:18:19.946: D/libEGL(28824): loaded /system/lib/egl/libGLESv2_adreno200.so
05-18 15:18:20.027: D/OpenGLRenderer(28824): Enabling debug mode 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:26:36+00:00Added an answer on June 4, 2026 at 4:26 am

    Since you have not posted the error logs, the following is a result of guess work.

    You are connecting to the server and parsing the HTML in the main/UI thread. This will make the main thread unresponsive and get terminated eventually (or a NetworkOnMainThreadException thrown). Take a look at Painless Threading to understand how you can perform a long duration task in the background and update the UI when it is complete.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't have any problem parsing WebView HTML or loading URLs (relative or absolute)
I'm having a problem on parsing a JSON from Google Places. I have the
I have some PHP code (written by someone else) that's parsing a html file
Ok, I have a very frustrating problem. I am parsing a webpage and need
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have an app that is parsing the html page and extracts some text
im just starting with lift and scala and have a problem i dont realy
I have to resolve a problem close to parsing a huge file like, 3
i am parsing an html page using XmlSlurper and HtmlCleaner, i have the GPathResult
I have a bunch of HTML I'm parsing with BeautifulSoup and it's been going

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.