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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:33:11+00:00 2026-06-02T01:33:11+00:00

I am trying (with a little python script) to put the content of a

  • 0

I am trying (with a little python script) to put the content of a HTML table from a online webpage in an Excel sheet.

All is working well, except the “Excel thing”.

#!/usr/bin/python
# --*-- coding:UTF-8 --*--

import xlwt
from urllib2 import urlopen
import sys
import re
from bs4 import BeautifulSoup as soup
import urllib

def BULATS_IA(name_excel):
    """ Function for fetching the BULATS AGENTS GLOBAL LIST"""

 ws = wb.add_sheet("BULATS_IA") # I add a sheet in my excel file

    Countries_List = ['United Kingdom','Albania','Andorra']
    Longueur = len(Countries_List)
    number = 1 


    print("Starting to fetch ...")

    for Countries in Countries_List:
        x = 0
        y = 0

        print("Fectching country %s on %s" % (number, Longueur))
        number = number + 1
        htmlSource = urllib.urlopen("http://www.cambridgeesol.org/institutions/results.php?region=%s&type=&BULATS=on" % (Countries)).read()
        s = soup(htmlSource)
        **tableauGood = s.findAll('table')
        try:
            rows = tableauGood[3].findAll('tr')
            for tr in rows:
                cols = tr.findAll('td')
                y = 0
                x = x + 1
                for td in cols:
                    hum =  td.text

                    ws.write(x,y,td.text)
                    y = y + 1
                    wb.save("%s.xls" % name_excel)**

        except (IndexError):
            pass

    print("Finished for IA")



name_doc_out = raw_input("What do you want for name for the Excel output document ? >>> ")
wb = xlwt.Workbook(encoding='utf-8')
print("Starting with BULATS Agents, then with BULATS IA")
#BULATS_AGENTS(name_doc_out)
BULATS_IA(name_doc_out)

—
So anything is going in the Excel Sheet, but when I print the content of the var … I see what I should see !

I’m trying to fix it since one hour but I still don’t understand what’s going one.
If some of you can give me a hand, It should be VERY nice.

  • 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-02T01:33:13+00:00Added an answer on June 2, 2026 at 1:33 am

    I have try your application. And I am very sure that the output of td.text is same as the excel file. So what’s your question? If the content is not what you want, you should check the usage of BeautifulSoap.
    Further more, you may need to do following:

               for td in cols:
                    hum =  td.text.replace(" ", " ")
                    print hum
                    ws.write(x,y,hum)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the following little Python script: #!/usr/local/bin/python2.5 import sys, subprocess child
Currently I'm trying to convert my little python script to support multiple threads/cores. I've
I have 0 experience with python, very little with regex and I'm trying to
I ran into a little error trying to select off of my table. I
I'm trying to write a little Emacs Lisp script that reads a csv file
i'm trying to use the terminal from python VTE binding (python-vte from debian squeeze)
I am trying to source a bash script containing some environment variables in python.
I'm trying to use VLC's python bindings to create my own little video player.
well,I wrote a little snappet trying to know how to use python threading .
I'm trying to convert some code from Python to C++ in an effort to

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.