-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.py
More file actions
31 lines (24 loc) · 825 Bytes
/
parse.py
File metadata and controls
31 lines (24 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re
# Fetch the html file
# response = urlopen('https://witness2.tech')
response = urlopen('file:///C:/Users/grant/Documents/GitHub/inline2css/test.html')
parsed_html = response.read()
# print(parsed_html)
soup = BeautifulSoup(parsed_html, 'html.parser')
# pretty_soup = soup.prettify()
# print(pretty_soup[:225])
print(soup.find_all(style=re.compile('background-color')))
id = 0
sections = []
sections.append(soup.find_all('section'))
# print(sections)
# for section in sections:
# if True in style:
# id = id + 1
# print(id, section, len(section))
# params = {'name': 'section', 'attrs': {'class': 'container'}}
# print( soup.find(**params).text )
# if param in soup.find_all('section'):
# print(soup.find_all('section'))