Development

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • BeautifulSoup error

    1 answers - 761 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    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(port)
  • No.1 | | 982 bytes | |

    "Serge " <S (AT) gmail (DOT) comwrites:

    []

    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(port)

    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,

    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 !

Re: BeautifulSoup error


max 4000 letters.
Your nickname that display:
In order to stop the spam: 8 + 7 =
QUESTION ON "Development"

EMSDN.COM