Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80145

Re: Installing Parsers/Tree Builders to, and accessing these packages from Python2.7

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'output': 0.05; 'tree': 0.05; 'nicely': 0.07; 'parser': 0.07; 'urllib2': 0.07; '__init__': 0.09; 'lawrence': 0.09; 'library?': 0.09; 'output,': 0.09; 'parsers': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'setup.py': 0.09; 'valueerror:': 0.09; 'python': 0.11; 'language.': 0.14; 'newlines': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'requisite': 0.16; 'subject: \n ': 0.16; 'subject:accessing': 0.16; 'url:packtpub': 0.16; 'all.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'command': 0.22; 'input': 0.22; 'import': 0.22; 'install': 0.23; 'header :User-Agent:1': 0.23; 'builder': 0.24; 'skip:" 40': 0.26; 'subject:/': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'installed': 0.27; 'tried': 0.27; 'went': 0.31; 'code': 0.31; '"",': 0.31; '>>>>': 0.31; 'subject:these': 0.31; 'file': 0.32; 'text': 0.33; 'says': 0.33; '(most': 0.33; 'skip:b 30': 0.33; "i'd": 0.34; 'subject:from': 0.34; "can't": 0.35; 'skip:u 20': 0.35; 'something': 0.35; 'but': 0.35; 'should': 0.36; 'wrong': 0.37; 'being': 0.38; 'expected': 0.38; 'skip:o 20': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'even': 0.60; 'above,': 0.60; 'subject: ': 0.61; 're:': 0.63; 'our': 0.64; 'more': 0.64; 'needing': 0.65; 'charset:windows-1252': 0.65; 'world': 0.66; 'due': 0.66; 'bottom': 0.67; 'beautiful': 0.68; 'detail.': 0.68; "'we": 0.84; 'received:2': 0.84; '2013,': 0.91; 'statutory': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Installing Parsers/Tree Builders to, and accessing these packages from Python2.7
Date Sun, 02 Nov 2014 22:31:48 +0000
References <9580043d-a75b-4b87-9a21-1b9c0347671f@googlegroups.com> <75794999-f188-470a-96d1-3d8fca80cbf7@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-2-98-204-224.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
In-Reply-To <75794999-f188-470a-96d1-3d8fca80cbf7@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15421.1414967524.18130.python-list@python.org> (permalink)
Lines 88
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1414967524 news.xs4all.nl 2896 [2001:888:2000:d::a6]:44387
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80145

Show key headers only | View raw


On 02/11/2014 21:59, Simon Evans wrote:
>
> Oh I don't mind quoting console output, I just thought I'd be sparing you
>
> unnecessary detail.
>
> output was going nicely as I input text from my 'Getting Started with
>
> Beautiful Soup' even when the author reckoned things would go wrong - due to
>
> lxml not being installed, things went right, because I had already installed
>
> it, re:
> ----------------------------------------------------------------------------
> page 17
> ----------------------------------------------------------------------------
> Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
> 32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import urllib2
>>>> from bs4 import BeautifulSoup
>>>> url = "http://www.packtpub.com/books"
>>>> page = urllib2.urlopen(url)
>>>> soup_packtpage = BeautifulSoup(page)
>>>> with open("foo.html","r") as foo_file:
> ... soup_foo = Soup(foo_file)
>    File "<stdin>", line 2
>      soup_foo = Soup(foo_file)
>             ^
> IndentationError: expected an indented block
>>>> soup_foo= BeautifulSoup("foo.html")
> ----------------------------------------------------------------------------
> page 18
> ----------------------------------------------------------------------------
>>>> print(soup_foo)
> <html><body><p>foo.html</p></body></html>
>>>> soup_url = BeautifulSoup("http://www.packtpub.com/books")
>>>> print(soup_url)
> <html><body><p>http://www.packtpub.com/books</p></body></html>
>>>> helloworld = "<p>Hello World</p>"
>>>> soup_string = BeautifulSoup(helloworld)
>>>> print(soup_string)
> <html><body><p>Hello World</p></body></html>
> ----------------------------------------------------------------------------
> page 19: no code in text on this page
> ----------------------------------------------------------------------------
> page 20
> ----------------------------------------------------------------------------
>>>> soup_xml = BeautifulSoup(helloworld,features= "xml")
>>>> soup_xml = BeautifulSoup(helloworld,"xml")
>>>> print(soup_xml)
> <?xml version="1.0" encoding="utf-8"?>
> <p>Hello World</p>
>>>> soup_xml = BeautifulSoup(helloworld,features = "xml")
>>>> print(soup_xml)
> <?xml version="1.0" encoding="utf-8"?>
> <p>Hello World</p>
>>>>
> ----------------------------------------------------------------------------
> Then on bottom of page 20 it says 'we should install the required parsers using easy-install,pip or setup.py install' but as I can't get the downloads of html or html5 parsers, text code halfway down returns statutory response regarding requisite parser needing to be installed, re:
> ----------------------------------------------------------------------------
> page 21
> ----------------------------------------------------------------------------
>>>> invalid_html = '<a invalid content'
>>>> soup_invalid_html = BeautifulSoup(invalid_html,'lxml')
>>>> print(soup_invalid_html)
> <html><body><a content="" invalid=""></a></body></html>
>>>> soup_invalid_html = BeautifulSoup(invalid_html,'html5lib')
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "C:\Python27\lib\site-packages\bs4\__init__.py", line 155, in __init__
>      % ",".join(features))
> ValueError: Couldn't find a tree builder with the features you requested: html5lib. Do you need to install a parser library?
>>>>

Have you tried this from the command prompt?

pip install html5lib

And please do something about the extra newlines and single lined 
paragraphs above, there's no need for it all.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-01 07:17 -0700
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Terry Reedy <tjreedy@udel.edu> - 2014-11-01 16:43 -0400
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-02 06:58 -0800
    Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-02 15:27 +0000
    Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Terry Reedy <tjreedy@udel.edu> - 2014-11-02 15:08 -0500
    Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Ned Batchelder <ned@nedbatchelder.com> - 2014-11-02 15:43 -0500
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-02 07:23 -0800
    Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-02 15:30 +0000
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-02 09:51 -0800
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-02 11:22 -0800
    Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-02 19:39 +0000
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-02 13:59 -0800
    Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-02 22:31 +0000
    Re: Installing Parsers/Tree Builders to, and accessing these packages from Python2.7 Chris Angelico <rosuav@gmail.com> - 2014-11-03 10:33 +1100
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-02 14:20 -0800
    Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-02 22:34 +0000
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-03 08:27 -0800
    Re: Installing Parsers/Tree Builders to, and accessing these packages from Python2.7 Chris Angelico <rosuav@gmail.com> - 2014-11-04 03:41 +1100
  Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Simon Evans <musicalhacksaw@yahoo.co.uk> - 2014-11-03 13:28 -0800
    Re: Installing Parsers/Tree Builders to, and accessing these packages from  Python2.7 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-03 21:42 +0000

csiph-web