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 9257711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:12:11+00:00 2026-06-18T12:12:11+00:00

I want parsing html site and get a string value. But i receive error

  • 0

I want parsing html site and get a string value. But i receive error when parsing div class.

<div class="content clear">

I wrote above code but i received error.

try {
        doc = Jsoup.connect("http://tvrehberi.hurriyet.com.tr/program-detay/308271/deli-deli-olma").get();

List<String> saatItem = new ArrayList<String>();
        for (Element  iterable : doc.getElementsByClass("content&clear")) {
            saatItem.add(iterable.text());

        }
catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

This error cause class have blank character. If class value hasn’t blank character, code runs perfectly.
How can i solve this problem ?

Error logs :

02-06 00:18:53.770: E/AndroidRuntime(28775): FATAL EXCEPTION: main
02-06 00:18:53.770: E/AndroidRuntime(28775): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.htmlparsingtutorial/com.example.htmlparsingtutorial.MainActivity}: android.os.NetworkOnMainThreadException
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.app.ActivityThread.access$600(ActivityThread.java:140)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.os.Looper.loop(Looper.java:137)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.app.ActivityThread.main(ActivityThread.java:4898)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at java.lang.reflect.Method.invokeNative(Native Method)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at java.lang.reflect.Method.invoke(Method.java:511)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at dalvik.system.NativeStart.main(Native Method)
02-06 00:18:53.770: E/AndroidRuntime(28775): Caused by: android.os.NetworkOnMainThreadException
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at java.net.InetAddress.getAllByName(InetAddress.java:214)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:408)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:393)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:159)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:148)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at com.example.htmlparsingtutorial.MainActivity.onCreate(MainActivity.java:90)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.app.Activity.performCreate(Activity.java:5206)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
02-06 00:18:53.770: E/AndroidRuntime(28775):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
02-06 00:18:53.770: E/AndroidRuntime(28775):    ... 11 more
  • 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-18T12:12:12+00:00Added an answer on June 18, 2026 at 12:12 pm

    Yes, this exception is thrown if you run networkcode in the main thread.
    The solution is to run your task as an AsyncTask.

    btw. please test this code, on PC it works:

    Document doc = Jsoup.connect("http://tvrehberi.hurriyet.com.tr/program-detay/308271/deli-deli-olma").get();
    
    List<String> saatItem = new ArrayList<String>();
    
    for( Element element : doc.select("div[class=content clear]"))
    {
        saatItem.add(element.text());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am parsing a HTML document with XPATH and I want to keep all
Basically I want to write a class for parsing XML document for my iphone
I am parsing html page now any of string comes from html page I
I'm parsing HTML page with XPath and want to grab whole text of some
I want to parse an HTML document and get all users' nicknames. They are
I have a string (@description) that contains HTML code and I want to extract
I have a big site with lots of .html files, and I want to
Hi at all I want to parsing a date from XML with this format:
I am new in android and i want to do parsing through api and
I parse a big xml document with Sax, I want to stop parsing the

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.