custom rendering of beautifulsoup object in ipython notebook and qtconsole
Project description
IPython-BeautifulSoup
IPython-BeautifulSoup is an IPython extension for displaying BeautifulSoup HTML/XML objects as prettified and syntax highlighted HTML blocks in IPython notebook and qtconsole.
Syntax highlighting is accomplished with Pygments.
Install
Simply run:
pip install "ipython-beautifulSoup[bs4]"
For BeautifulSoup 3 instead of BeautifulSoup 4, change bs4 to bs3.
Installing IPython Notebook
See http://ipython.org/ipython-doc/stable/install/index.html
To install IPython notebook or qtconsole as well, append notebook and/or qtconsole to the extras specifier after “bs4” separated by a “,”, like this:
pip install "ipython-beautifulSoup[bs4,notebook,qtconsole]"
On Ubuntu LTS, if you want to install IPython notebook, you’ll need to do this before:
sudo apt-get install python-dev g++
For the qtconsole do this (if you do this in a virtualenv) (WARNING: it’s slow):
sudo apt-get install make cmake qt4-qmake libqt4-dev pip install pyside
Usage
In IPython notebook or qtconsole, do:
%load_ext soup
This will push a series of callables into your current context, as well as a monkey-patched BeautifulSoup and requests.
You can now use BeautifulSoup like you would if it was imported from the corresponding module.
There is great chances that you’ll want to configure the output by using configure_ipython_beautifulsoup, for example like this (just after the %load_ext):
configure_ipython_beautifulsoup(show_html=True, show_css=True, show_js=False)
To see configure_ipython_beautifulsoup documentation just do (in any interface of IPython):
configure_ipython_beautifulsoup?
This also loads a shortcut function called p (for p arse) defined as follows:
def p(url): if requests is not None: return BeautifulSoup(requests.get(url).contents) return BeautifulSoup(urlopen(url).read())
A note on security
The most safe option is to set all options of configure_ipython_beautifulsoup to False (the default).
Screenshots
IPython Notebook
.find:
.findAll:
Contributors
In chronological order:
Astalaseven - pull request: #1
Don’t hesitate to add yourself.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for ipython-beautifulsoup-0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ce3027a982702453e961e4964203b77fd74380ea5bde82273b241f7afc658c8 |
|
MD5 | f7e04347c27264b076d2d453bbdd509b |
|
BLAKE2b-256 | bde591e1e5458e55edadda9943ea3c954bc728763e9b655883083c892891fc81 |
Hashes for ipython_beautifulsoup-0.2-py27-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9d6842906743be76cf54da52489186cb7985e9b9b37bf443d76197d43a3bd5a |
|
MD5 | 3f3fcad57b0cc36328caf6c727e7c810 |
|
BLAKE2b-256 | 37016286be02f7a5c141df41c0311fa7a88ba976601525b9922dbfad69c9cdc6 |
Hashes for ipython_beautifulsoup-0.2-py2.7.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83072cc4340690691634e833b200baf42b7ec1eb40bc5425e5d0f8f11f397b54 |
|
MD5 | f31266a11174ac697e751a4f882e0dd3 |
|
BLAKE2b-256 | 927e58c0cc17d53c406fc1cc9b1f48ed04354a8d5b3dc977f19095fedce726dc |