Hi,
should the HTMLParser be able to handle unicode input? I get the following
traceback:
self.feed(self. data)
File "C:\Python23\li b\sgmllib.py", line 94, in feed
self.goahead(0)
File "C:\Python23\li b\sgmllib.py", line 183, in goahead
self.handle_ent ityref(name)
File "C:\Python23\li b\sgmllib.py", line 390, in handle_entityre f
self.handle_dat a(table[name])
File "C:\Python23\li b\htmllib.py", line 49, in handle_data
self.savedata = self.savedata + data
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0xa0 in position 0:
ordinal not in range(128)
The input is a html page from the web, encoded as utf8. I converted the
string via data.decode('ut f8'). The result is passed to the feed function.
regards,
Achim 0 1738 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: 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: Dfenestr8 |
last post by:
Hi.
I want a routine that strips a line of html of all it's tags. e.g I want
it to turn ....
"<p><b>This is an <h1><blink>IRRITATING</blink></h1> line of </b>text</p>"
.... into ......
"This is an IRRITATING line of text"
|
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: geir.smestad |
last post by:
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
| |
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: axjacob |
last post by:
I am using html and formater as shown below. They are used as part of a larger program.
Even though I don't use any print statements, the htmllib seems to be throwing parts of the html page on to the standard out(my screen in this case). Is there a way to disable the output?
import htmllib
w = formatter.DumbWriter()
format = formatter.AbstractFormatter(w)
p = htmllib.HTMLParser(format)
p.feed(inhtml)
p.close()
|
by: jonbutler88 |
last post by:
Just writing a simple website spider in python, keep getting these
errors, not sure what to do. The problem seems to be in the feed()
function of htmlparser.
Traceback (most recent call last):
File "spider.py", line 38, in <module>
s.crawl(site)
File "spider.py", line 30, in crawl
self.parse(url)
File "spider.py", line 21, in parse
|
by: globalrev |
last post by:
tried all kinds of combos to get this to work.
http://docs.python.org/lib/module-HTMLParser.html
from HTMLParser import HTMLParser
class MyHTMLParser(HTMLParser):
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |