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.DumbW riter(outfile)
f = formatter.Abstr actFormatter(w)
p = htmllib.HTMLPar ser(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 2309
<ge**********@g mail.com> wrote in message
news:11******** **************@ i40g2000cwc.goo glegroups.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**********@gm ail.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 the </TR> tags.
Apparently, htmllib and more likely sgmllib do not parse an end tag if a
corresponding start tag was not found. Does anyone know a way to "fool"
the parser into handling the end tag is a start tag was not found?
Thanks,
|
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 "C:\Python23\lib\sgmllib.py", line 183, in goahead
self.handle_entityref(name)
|
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 between tags
(in the case of product description, the tag is font).
To capture product descriptions, I've been using the save_bgn() and
save_end() methods. But I've noticed that the result of save_end() only
includes text that isn't marked up. ...
|
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 (the HTML in self.contents is
UTF-8 encoded):
file = cStringIO.StringIO()
|
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 regular python2.4).
Using -v traceback gives:
| |
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 <bodybegins to where </bodyends. I start by doing
class HTMLBody(HTMLParser):
def __init__(self):
self.contents =
|
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 com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;
|
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 javax.servlet.*;
import javax.servlet.http.*;
import com.wrox.proj2ee.ch12.*// The requesthandlers interface in this package.
public class ShowRecordRequesthandler implements RequestHandler
|
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)
Location: class Week5MortgageGUI
Week5MortgageLogic allint = logic.allInterest(amount, term, rate);
Week5MortgageGUI.java:152:cannot find symbol
symbol: method allInterest(double,double,double)
Location: class Week5MortgageGUI
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |