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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:27:33+00:00 2026-06-14T22:27:33+00:00

I need to categorize this html page http://gnats.netbsd.org/summary/year/2012-perf.html , I need to make a

  • 0

I need to categorize this html page http://gnats.netbsd.org/summary/year/2012-perf.html , I need to make a list of top issues just from the big table.This is my code in Python.I would be really gratefull if you could give me some advice.

    import urllib.request
from bs4 import BeautifulSoup

# overall input
inputpage = urllib.request.urlopen("http://gnats.netbsd.org/summary/year/2012-perf.html")
page = inputpage.read()
soup = BeautifulSoup(page)

# checking tables
table = soup.findAll('table')
rows = soup.findAll('tr')
colomns = soup.findAll('td')

# inputing the lists
name = []
first = []
second = []
sum = []

# the main part
for tr in rows:
    if (tr==1):
        element = tr.split("<td>")
        name.append(element)
    elif (tr==2):
        element = tr.split("<td>")
        first.append(element)
    elif (tr==3):
        element = tr.split("<td>")
        second.append(element)


# combining the open and closed issue lists
length = len(first)
for i in range(length):
    sum = first[i] + second [i]

# printing the lists
length = len(sum)
for i in range(length):
    print (name[i] + '|' + sum[i])
  • 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-14T22:27:34+00:00Added an answer on June 14, 2026 at 10:27 pm

    BeautifulSoup has some nice methods for accessing child nodes and so on. You could for example use tables = soup.findAll('table'). Assuming you want to combine the data of the second table in the link you posted (tables[1]), you could do something like the following

    names = []
    cdict = {0:[], 1:[]} # dictionary of "td positions to contents"
    
    tables = soup.findAll('table')
    for tt in tables[1].find_all('tr')[1:]: # skip first <tr> since it is the header
        names.append(tt.find_all('th')[0]) # 1st column is a th with the name
        for k, v in cdict.items():
            # append the <td>text</td> of column k to the corresponding list
            v.append(tt.find_all('td')[k].text)
    

    So, what you’ll end up with is a dictionary of columns -> lists, so that
    each list contains the td text elements (the main reason for using a dictionary
    is because you may want to grab the elements from columns 1,2 and 4, in which case
    you’ll only need to change what is in the cdict).

    To make the sums you can do something like:

    for i in xrange(len(names)):
        print names[i], int(cdict[0][i]) + int(cdict[1][i])
    

    If you have a look at each element’s methods you’ll see some really nice functionality you can use to make your task easier.

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

Sidebar

Related Questions

For this collapsible menu in this page: http://2ddige.com/temps/Services/proteomics%202d_dige_copy%281%29.html What changes need to be made
I am wanting to rewrite a url like: http://my.project/mydomain.com/ANY_NUMBER_OF_CATEGORIES/designer/4/designer-name/page.html to this: http://my.projects/mydomain.com/ANY_NUMBER_OF_CATEGORIES/page.html?designer=4 I would
I need to list sibling categories in the category page in a Prestashop theme.
I need to output to HTML a list of categorized links in exactly three
I have an xml file which I imported in my html page like this:
I need to analyze a users' post and categorize it. For example: I have
On page 1 of a mobile app I need to display categories from a
Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
Need a map reduce function by mongo in php This my mongo structure [_id]
I have a page with a search bar, facets, and a list of results.

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.