Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

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.

Files for soupcan, version 0.0.1a1
Filename, size File type Python version Upload date Hashes
Filename, size soupcan-0.0.1a1-py3-none-any.whl (7.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size soupcan-0.0.1a1.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page