Parse HTML Components
This page explains how to parse and extract information from a page (local or remote).
The process
$ pip install requests
$ pip install lxml
$ pip install beautifulsoup4

Resources
Last updated
This page explains how to parse and extract information from a page (local or remote).
$ pip install requests
$ pip install lxml
$ pip install beautifulsoup4

Last updated
$ python [ENTER]
>>>>>> f = open('./app/templates/index.html','r')
>>> html_page = f.read()>>> import requests
>>> page = requests.get('https://demo.themesberg.com/pixel-lite/index.html')
>>> html_page = page.content//*[@id="features"]>>> from lxml import html
>>> html_dom = html.fromstring( html_page )
>>> component = html_dom.xpath( '//*[@id="features"]' )
>>> from lxml.etree import tostring
>>> component_html = tostring( component[0] )>>> from bs4 import BeautifulSoup as bs
>>> soup = bs( component_html )
>>> soup.prettify() <section class="section section-lg pb-0" id="features">
<div class="container">
<div class="row">
...
<div class="col-12 col-md-4">
<div class="icon-box text-center mb-5 mb-md-0">
<div class="icon icon-shape icon-lg bg-white shadow-lg border-light rounded-circle icon-secondary mb-3">
<span class="fas fa-box-open">
</span>
</div>
<h2 class="my-3 h5">
80 components
</h2>
<p class="px-lg-4">
Beatifully crafted and creative components made with great care for each pixel
</p>
</div>
</div>
...
</div>
</div>
</div>
</section>