Using Ubuntu Breezy Badger 5.10. I get the following traceback:
-----
Traceback (most recent call last):
File "/home/geir/programmering/htmlparse/formatter.py", line 1, in
-toplevel-
import formatter
File "/home/geir/programmering/htmlparse/formatter.py", line 2, in
-toplevel-
import htmllib
File "/usr/lib/python2.4/htmllib.py", line 9, in -toplevel-
from formatter import AS_IS
ImportError: cannot import name AS_IS
-----
I have been unable to make the following code execute on my Ubuntu
system, and the error above started occurring after I attempted to
execute it. Libraries were imported successfully:
-----
#!/usr/bin/python
import formatter
import htmllib
import urllib
import iface
def fetch(url):
"""Fetches URL to string"""
object = urllib.urlopen(url)
string = object.read()
return string
def plaintext(data, outfile):
"""Formats HTML to plain-text outfile"""
w = formatter.DumbWriter(outfile)
f = formatter.AbstractFormatter(w)
p = htmllib.HTMLParser(f)
p.feed(data)
p.close()
-----
I do not have a copy of the traceback, but the final message was
something along the lines of 'str' object does not have attribute
'write'.
As far as I can see, the files formatter.py and htmllib.py are where
they are supposed to be, in /usr/lib/python2.4/.
Geir Smestad 3 2277
<ge**********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com... As far as I can see, the files formatter.py and htmllib.py are where they are supposed to be, in /usr/lib/python2.4/.
You probably have aliased it by calling your main program formatter.py,
or something similar. ge**********@gmail.com wrote: ----- Traceback (most recent call last): File "/home/geir/programmering/htmlparse/formatter.py", line 1, in -toplevel- import formatter File "/home/geir/programmering/htmlparse/formatter.py", line 2, in -toplevel- import htmllib File "/usr/lib/python2.4/htmllib.py", line 9, in -toplevel- from formatter import AS_IS ImportError: cannot import name AS_IS -----
As far as I can see, the files formatter.py and htmllib.py are where they are supposed to be, in /usr/lib/python2.4/.
not only that, but according to the traceback, you also have a formatter
module under
/home/geir/programmering/htmlparse
(by default, the current directory is part of the system path).
</F>
Thanks a lot! You are quite right.
(By the way, this is the first time ever I post something to a
newsgroup. Thanks for giving me a good first impression :D) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: KC |
last post by:
I have written a parser using htmllib.HTMLParser and it functions fine
unless the HTML is malformed. For example, is some instances, the
provider of the HTML leaves out the <TR> tags but includes...
|
by: Achim Domma |
last post by:
Hi,
should the HTMLParser be able to handle unicode input? I get the following
traceback:
self.feed(self.data)
File "C:\Python23\lib\sgmllib.py", line 94, in feed
self.goahead(0)
File...
|
by: jennyw |
last post by:
I'm trying to parse a product catalog written in HTML. Some of the
information I need are attributes of tags (like the product name, which
is in an anchor). Some (like product description) are...
|
by: Morten W. Petersen |
last post by:
Hi,
I have an HTML page that displays some content, and a part of that
content is HTML changed into regular text. The encoding of the page
is UTF-8.
Here's the code that makes the change...
|
by: huwjeffries |
last post by:
Hi There,
I've installed python2.4-dev on Unbuntu linux. When I run it, it gives
an error:
'import site' failed; use -v for traceback
(Get the same result if I uninstall it and install...
|
by: David Bear |
last post by:
I'm trying to understand how to use the HTMLParser in htmllib but I'm not
seeing enough examples.
I just want to grab the contents of everything enclosed in a '<body>' tag,
i.e. items from where...
|
by: vsp15584 |
last post by:
Hii..i use the coding as below :-
import java.applet.applet;
import java.awt.*;
import com.sun.j3d.utils.applet.mainframe;
import com.sun.j3d.utils.universe.*;
import...
|
by: Shiva48 |
last post by:
Thanks to Gannon11 and ro351988- Moderator.
I give below the complete Java file and pls help me to rectify the errors.
package com.wrox.proj2ee.ch10.app;
import java.io.*;
import...
|
by: karinmorena |
last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is:
Week5MortgageGUI.java:151:cannot find symbol
symbol: method allInterest(double,double,double)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |