Re: step 1 from doc = soup=BeautifulSoup(html_doc)

445 views
Skip to first unread message

Sparky

unread,
Feb 12, 2013, 12:12:28 PM2/12/13
to beauti...@googlegroups.com

On Tuesday, February 12, 2013 10:31:48 AM UTC-6, Sparky wrote:
Greetings,
 
I have Python 2.7 and have installed Beautiful Soup
the "from bs4 import BeautifulSoup"  works
 
I have created (copied and pasted) the html_doc from the documentation.
 
When I execute "soup = BeautifulSoup(html_doc) I get "
 
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    soup = BeautifulSoup(htmldoc2)
NameError: name 'htmldoc2' is not defined"
 
help?
 
Thanks

Sparky

unread,
Feb 12, 2013, 12:12:50 PM2/12/13
to beauti...@googlegroups.com

Never mind – for completeness, let me explain in case it helps somebody.

This line (from the documentation: http://www.crummy.com/software/BeautifulSoup/bs4/doc/#name ) gives the error:

soup = BeautifulSoup(html_doc)

This Line works:

soup = BeautifulSoup (open("html_doc.html"))

I found the “open” syntax searching around.

-Sparky

Reply all
Reply to author
Forward
0 new messages