Skip to main content

a Python library for creating custom objects of webpage content

Project description

# soupcan

soupcan is a Python library for creating interface objects of webpage content. Using [Requests](http://docs.python-requests.org/en/master/) and [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/index.html?highlight=setup#beautiful-soup-documentation) under the hood, this library make it easy to design modular interfaces for selected HTML content, or groups of content, found on a webpage. Anyone needing a way to build interfaces to display and analyse web content are welcome to use this library. The ideal for use in a Jupyter notebook.

## Installation

<a href="https://notebooks.azure.com/import/gh/stephenmccalman/soupcan"><img src="https://notebooks.azure.com/launch.png" /></a>

## Basic Usage

Retrieve a webpage:
~~~
import soupcan
page = soupcan.BasePage.from_url({URL})
print(page.title)
print(page.url)
~~~

Access a table (content) from a page using `soupcan`'s (pre-designed) `Table` class:
~~~
from soupcan.common import Table
table = page.get(Table)
print(table.body.rows[0])
~~~

Create your own custom interface object:
~~~
class MyTableHeader(soupcan.Interface):
_soup_kwargs = {"name": 'thead'}

class MyTableBody(soupcan.Interface):
_soup_kwargs = {"name": 'tbody'}

class MyTable(soupcan.Interface):
_soup_kwargs = {"name": 'table'}

@property
def header(self):
self.get(MyTableHeader)

@property
def body(self):
self.get(MyTableBody)

mytable = page.get(MyTable)

print(mytable.header) #
print(mytable.body) #
~~~

## Disclamer



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
soupcan-0.0.1a1-py3-none-any.whl (7.3 kB) Copy SHA256 hash SHA256 Wheel py3
soupcan-0.0.1a1.tar.gz (4.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page