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

  • SEARCH
  • Home
  • 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 8117993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:20:36+00:00 2026-06-06T04:20:36+00:00

I am trying to get the results of this code this way: title: Ben

  • 0

I am trying to get the results of this code this way:

title: Ben 10 Ultimate Alien

comment:taseen_shafquattaseen_shafquat : is there go na a season 4 for
this series

title: Akira

comment: dragon3476dragon3476 : one of my most fav animations
excellent bit o work and about my 300th watch , i still got the
orginal poster from when it came out + dvd and vid and even the
t-shirt so yeah i couldn’t say anything bad about such a great
animation 5/5

But, I get it this way instead:

title: Ben 10 Ultimate Alien

title: taseen_shafquattaseen_shafquat : is there go na a season 4 for
this series

title: Akira

title: dragon3476dragon3476 : one of my most fav animations excellent
bit o work and about my 300th watch , i still got the orginal poster
from when it came out + dvd and vid and even the t-shirt so yeah i
couldn’t say anything bad about such a great animation 5/5

Code

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.nodes.Node;
import org.jsoup.select.Elements;

import java.io.*;
import java.util.List;

public class WebScraper {

    public static void main(String[] args) throws Exception {
        String url = "http://www.1channel.ch/latest_comments.php";
        Document doc = Jsoup.connect(url).get();
        for (Element E : doc.select("div.latest_comments > a, div.latest_comments > p")) {

         System.out.print("title: "+ E.getElementsByTag("a").text());
         System.out.println(  E.getElementsByTag("p").text());
          //    System.out.println(T);
            System.out.print("\n");

            try 
            {
            PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("/Users/samualdoku/Desktop/Twitter/scraped.txt", true)));
            out.println(E.text());
            out.close();
             } catch (IOException e) {
            }  
        }

    }

}

And this is the html I am trying to scrape. I think the problem lies with the href tag inside the span. It contains the commenter usernames. I called getElementsByTag("a") for the title because the title is within an anchor tag. How do I get rid of the span tag, because it prints the title in front of the user names which shouldn’t be so.

 <div class="latest_comments com_class_tv">
    <a href="/tv-2733767-Dallas/season-1-episode-3">Dallas</a>
    ( 6 minutes ago )
    <p>
        <span class="latest_comments_poster">
          <a href="/profile/jowar">jowar</a>
          :
        </span>
        i just started watchin...eeing as its 34nyrs old
    </p>
</div>
  • 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-06T04:20:37+00:00Added an answer on June 6, 2026 at 4:20 am

    Try this

    public static void main(String[] args) throws Exception {
     String url = "http://www.1channel.ch/latest_comments.php";
     Document doc = Jsoup.connect(url).get();
     for (Element E : doc.select("div.latest_comments)) {
    
      System.out.print("title: "+ E.select("a").text());
      System.out.println("comment: " + E.select("p").text());
    
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Entity Framework. I am trying to get the results from linq
I'm trying to build up a string array in JavaScript and get the results
I am a bit puzzled with my Regex results (and still trying to get
I have a 3 tables that I'm trying to join and get distinct results.
I'm trying to use $.post within a function, get the results, then return the
I am trying the following query and get only zero results (I am supposed
I'm trying to use the jQuery get function to render the results of an
Experimenting with Spring-JDBC. I am using this as reference. I am trying to get
Is there anything wrong with the thread safety of this java code? Threads 1-10
Is there a way to make Java Exceptions more informative? For example, take this

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.