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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:14:25+00:00 2026-06-16T15:14:25+00:00

I have some html code that contains many <table> s in it. I’m trying

  • 0

I have some html code that contains many <table>s in it.

I’m trying to get the information in the second table. Is there a way to do this without using soup.findAll('table') ?

When I do use soup.findAll('table'), I get an error:

ValueError: too many values to unpack

Is there a way to get the n-th tag in some code or another way that does not require going through all the tables? Or should I see if I can add titles to the tables? (like <table title="things">)

There are also headers (<h4>title</h4>) above each table, if that helps.

Thanks.

EDIT

Here’s what I was thinking when I asked the question:

I was unpacking the objects into two values, when there were many more. I thought this would just give me the first two things from the list, but of course, it kept giving me the error mentioned above. I was unaware the return value was a list and thought it was a special object or something and I was basing my code off of my friends’.

I was thinking this error meant there were too many tables on the page and that it couldn’t handle all of them, so I was asking for a way to do it without the method I was using. I probably should have stopped assuming things.

Now I know it returns a list and I can use this in a for loop or get a value from it with soup.findAll('table')[someNumber]. I learned what unpacking was and how to use it, as well. Thanks everyone who helped.

Hopefully that clears things up, now that I know what I’m doing my question makes less sense than it did when I asked it, so I thought I’d just put a note here on what I was thinking.

EDIT 2:

This question is now pretty old, but I still see that I was never really clear about what I was doing.

If it helps anyone, I was attempting to unpack the findAll(...) results, of which the amount of them I didn’t know.

useless_table, table_i_want, another_useless_table = soup.findAll("table");

Since there weren’t always the amount of tables I had guessed in the page, and all the values in the tuple need to be unpacked, I was receiving the ValueError:

ValueError: too many values to unpack

So, I was looking for the way to grab the second (or whichever index) table in the tuple returned without running into errors about how many tables were used.

  • 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-16T15:14:27+00:00Added an answer on June 16, 2026 at 3:14 pm

    To get the second table from the call soup.findAll('table'), use it as a list, just index it:

    secondtable = soup.findAll('table')[1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML code that contains nested <ul> elements and I need to
I have an HTML textbox that contains some SQL code that I need executed.
I have some PHP code that generates a calendar and then outputs html to
I have a jquery line of code that outputs some HTML to a div.
I have some HTML that contains a JSON string. In the on DOM ready
I have a function that appen some html code to my already existing div
I have some code that works fine but it's become too slow: HTML: I
I have a div that contains some html and a lot of Javascript <div
In HTML, I have a div that contains a table of labels and textboxes
I have some HTML code that looks like this: <tr id=nbContent_GR1>...</tr> <tr id=nbContent_GR2>...</tr> <tr

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.