-
Notifications
You must be signed in to change notification settings - Fork 0
/
eduardocavalcanti.py
36 lines (27 loc) · 948 Bytes
/
eduardocavalcanti.py
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
32
33
34
35
36
import bs4
import requests
import sqlite3
from urllib.request import urlopen
def parseSite(papel):
# set URL to be opened
myUrl = 'https://eduardocavalcanti.com/an_fundamentalista/' + papel + '/'
print(myUrl)
# open web page and get HTML data
myClient = urlopen(myUrl)
myPage_html = myClient.read()
myClient.close()
# html parsing
mySoup = bs4.BeautifulSoup(myPage_html,'html.parser')
# decode the parsed html into elements
#myTable = mySoup.table
myTable = mySoup.find('table', attrs={ 'class' : 'table table-hover table-condensed table-responsive analise'})
myHeaders = [header.text for header in myTable.find_all('th')]
print(myHeaders)
myRows = []
for row in myTable.tbody.find_all('tr'):
myRows.append([paramId] + [val.text for val in row.find_all('td')])
print(myRows)
return myRows
retRows = parseSite('tiet')
for row in retRows:
print(row)