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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:46:42+00:00 2026-05-28T18:46:42+00:00

When I scrape a site using jsoup I am getting extra values that I

  • 0

When I scrape a site using jsoup I am getting extra values that I do not want to recieve.
I only want to recieve his name not his team and position. Currently it is also scraping the position and team. I only want to recieve the name.

Page Source:

<td class="playertableData">5</td><td class="playertablePlayerName" id="playername_515" style=""><a href="" class="flexpop" content="tabs#ppc" instance="_ppc" fpopHeight="357px" fpopWidth="490px" tab="null" leagueId="0" playerId="515" teamId="-2147483648" cache="true">Derrick Rose</a>, Chi&nbsp;PG<a href="" class="flexpop" content="tabs#ppc" 

My Code:

while (tdIter.hasNext()) {
                        int tdCount = 1;
                        Element tdEl = tdIter.next();
                        name = tdEl.getElementsByClass("playertablePlayerName")
                                .text();

                        Elements tdsEls = tdEl.select("td.playertableData");
                        Iterator<Element> columnIt = tdsEls.iterator();

                        namelist.add(name);

OUTPUT:

 name: Derrick Rose, Chi PG
  • 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-05-28T18:46:43+00:00Added an answer on May 28, 2026 at 6:46 pm

    You are doing it wrong. By the line,

    name = tdEl.getElementsByClass("playertablePlayerName").text();
    

    you will get the complete text of the with class=”playertablePlayerName” which includes an anchor tag and a plane text outside any tag. Means, you will get

    Derric Rose, Chi PG
    

    Which is your output. To solve this issue, you must include the condition for th anchor tag too. Try using the belove line as a replacement.

    doc = Jsoup_Connect.doHttpGet();
    Elements tdsEls = doc.getElementsByClass("playertablePlayerName");
    name = tdsEls.get(0).child(0).text();
    

    You can traverse through the child of the td you have already got. When you get correct tag, use the chained text() method.

    Feel free to ask if you have any doubt.

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

Sidebar

Related Questions

I am using JSOUP to scrape data from a table on a site that
Is it possible to scrape all the text from a site that was navigated
I want to scrape some information off a football (soccer) web page using simple
Hey can someone help with the following? I'm trying to scrape a site that
The site that I'm trying to scrape uses js to create a cookie. What
I'm an amateur programmer wanting to scrape data from a site that is similar
How can I scrape a site using a User-Agent for Ipad? I have this
I'm using C#, and I'd like to scrape all the content on a site
I'm trying to scrape a website using some regex. But the site isn't written
I'm trying to scrape a price from a web page using PHP and Regexes.

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.