Hi, all,
This piece of code used to work well. i guess the error occurs after
some upgrade. import urllib from BeautifulSoup import BeautifulSoup url = 'http://www.google.com' port = urllib.urlopen( url).read() soup = BeautifulSoup() soup.feed(port)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/sgmllib.py", line 94, in feed
self.rawdata = self.rawdata + data
UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0xb8 in position 565: ordinal not in range(128)
Any ideas to solve this?
version info:
Python 2.3.5 (#2, Mar 7 2006, 12:43:17)
[GCC 4.0.3 20060212 (prerelease) (Debian 4.0.2-9)] on linux2
python-beautifulsoup: 3.0.1-1
--
William
"I'd love to go out with you, but I have to floss my cat." 4 2727
William Xu wrote: Hi, all,
This piece of code used to work well. i guess the error occurs after some upgrade.
import urllib from BeautifulSoup import BeautifulSoup url = 'http://www.google.com' port = urllib.urlopen( url).read() soup = BeautifulSoup() soup.feed(port) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.3/sgmllib.py", line 94, in feed self.rawdata = self.rawdata + data UnicodeDecodeEr ror: 'ascii' codec can't decode byte 0xb8 in position 565: ordinal not in range(128) Any ideas to solve this?
According to the documentation
<http://www.crummy.com/software/BeautifulSoup/documentation.h tml>
chapter "Beautiful Soup Gives You Unicode, Dammit" Beautiful Soup fully
supports unicode so it's probably a bug.
version info:
Python 2.3.5 (#2, Mar 7 2006, 12:43:17) [GCC 4.0.3 20060212 (prerelease) (Debian 4.0.2-9)] on linux2
python-beautifulsoup: 3.0.1-1
Upgrading python-beautifulsoup is a good idea, since there were two bug
fix releases after 3.0.1
"Serge Orlov" <Se*********@gm ail.com> writes:
[...] Upgrading python-beautifulsoup is a good idea, since there were two bug fix releases after 3.0.1
I just downloaded latest version 3.0.3 from its homepage, seems it still
has the same problem.
--
William
PL/I -- "the fatal disease" -- belongs more to the problem set than to the
solution set.
-- Edsger W. Dijkstra, SIGPLAN Notices, Volume 17, Number 5
William Xu wrote: Hi, all,
This piece of code used to work well. i guess the error occurs after some upgrade.
import urllib from BeautifulSoup import BeautifulSoup url = 'http://www.google.com' port = urllib.urlopen( url).read() soup = BeautifulSoup() soup.feed(port)
Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.3/sgmllib.py", line 94, in feed
Look at the traceback: you're not calling BeautifulSoup module! In
fact, there is no feed method in the current BeautifulSoup
documentation. Maybe it used to work well, but now it's definitely
going to fail. As I understand documentation you need to write
soup = BeautifulSoup(p ort)
"Serge Orlov" <Se*********@gm ail.com> writes:
[...] Look at the traceback: you're not calling BeautifulSoup module! In fact, there is no feed method in the current BeautifulSoup documentation. Maybe it used to work well, but now it's definitely going to fail. As I understand documentation you need to write
soup = BeautifulSoup(p ort)
Ah, yes ! Things change ! :-)
BeautifulSoup feed() method used to exist before 3.0.0, and was left
over to SGMLParser later. As explained in the changlog, http://www.crummy.com/software/Beaut...CHANGELOG.html
Release 3.0.0 (2006/05/28), "Who would not give all else for two p"
Beautiful Soup no longer implements a feed method. You need to pass a
string or a filehandle into the soup constructor, not with feed after
the soup has been created. There is still a feed method, but it's the
feed method implemented by SGMLParser and calling it will bypass
Beautiful Soup and cause problems.
Thanks for all the help !
--
William
Thrashing is just virtual crashing. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steve Young |
last post by:
I tried using BeautifulSoup to make changes to the url
links on html pages, but when the page was displayed,
it was garbled up and didn't look right (even when I
didn't actually change anything on the page yet). I
ran these steps in python to see what was up:
>>from BeautifulSoup import BeautifulSoup
>>from urllib2 import build_opener, Request
>>
>>req = Request('http://www.python.org/')
|
by: ye juan |
last post by:
Hi,
Anyone tries to use BeautifulSoup (
http://www.crummy.com/software/BeautifulSoup/ ) in
Jython? I can not run that ,the error that Jython
gives me is: unpack sequence too long.
Sincerely,
Erica
|
by: Gonzillaaa |
last post by:
I'm trying to get the data on the "Central London Property Price Guide"
box at the left hand side of this page
http://www.findaproperty.com/regi0018.html
I have managed to get the data :) but when I start looking for tables I
only get tables of depth 1 how do I go about accessing inner tables?
same happens for links...
this is what I've go so far
|
by: John Nagle |
last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally
hit content which has something like "Design & Advertising", that is,
an "&" instead of an "&". Is there some way I can get BeautifulSoup
to clean those up? There are various parsing options related to "&"
handling, but none of them seem to do quite the right thing.
If I write the BeautifulSoup parse tree back out with "prettify",
the loose "&" is still in there. So...
|
by: John Nagle |
last post by:
This, which is from a real web site, went into BeautifulSoup:
<param name="movie" value="/images/offersBanners/sw04.swf?binfot=We offer
fantastic rates for selected weeks or days!!&blinkt=Click here
And this came out, via prettify:
<addresssnippet siteurl="http%3A//apartmentsapart.com"
url="http%3A//www.apartmentsapart.com/Europe/Spain/Madrid/FAQ">
<param name="movie" value="/images/offersBanners/sw04.swf?binfot=We offer
| |
by: Mizipzor |
last post by:
Is there a way to "subscribe" to individual topics? im currently
getting bombarded with daily digests and i wish to only receive a mail
when there is activity in a topic that interests me. Can this be done?
Thanks in advance.
|
by: John Nagle |
last post by:
The syntax that browsers understand as HTML comments is much less
restrictive than what BeautifulSoup understands. I keep running into
sites with formally incorrect HTML comments which are parsed happily
by browsers. Here's yet another example, this one from
"http://www.webdirectory.com". The page starts like this:
<!Hello there! Welcome to The Environment Directory!>
<!Not too much exciting HTML code here but it does the job! >...
|
by: Larry Bates |
last post by:
Info:
Python version: ActivePython 2.5.1.1
Platform: Windows
I wanted to install BeautifulSoup today for a small project and decided to use
easy_install. I can install other packages just fine. Unfortunately I get the
following error from BeautifulSoup installation attempt:
C:\Python25\Lib\SITE-P~1>easy_install BeautifulSoup
|
by: bsagert |
last post by:
I downloaded BeautifulSoup.py from http://www.crummy.com/software/BeautifulSoup/
and being a n00bie, I just placed it in my Windows c:\python25\lib\
file. When I type "import beautifulsoup" from the interactive prompt
it works like a charm. This seemed too easy in retrospect.
Then I downloaded the PIL (Python Imaging Library) module from
http://www.pythonware.com/products/pil/. Instead of a simple file that
BeautifulSoup sent me, PIL is...
|
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: 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: 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: 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...
| |