/
topcompanies
42 lines (32 loc) · 1.02 KB
/
topcompanies
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
37
38
39
40
41
42
import csv
import requests
from beautifulsoup import beautifulsoup
import requests
url = 'http://www.conferenceseries.com/materials-science-meetings'
response = requests.get(url)
html = response.content
soup = BeautifulSoup(html)
table = soup.find('ul', attrs={'type': 'disc'})
for row in table.findAll('li'):
for cell in row.findAll('td'):
print cell.text
for row in table.findAll('tr'):
for cell in row.findAll('td'):
print cell.text.replace(' ', '')
for row in table.findAll('tr'):
list_of_cells = []
for cell in row.findAll('td'):
text = cell.text.replace(' ', '')
list_of_cells.append(text)
print list_of_cells
list_of_rows = []
for row in table.findAll('tr'):[1:]:
list_of_cells = []
for cell in row.findAll('td'):
text = cell.text.replace(' ', '')
list_of_cells.append(text)
list_of_rows.append(list_of_cells)
print list_of_rows
outfile = open("./topcompanies.csv", "wb")
writer = csv.writer(outfile)
writer.writerows(list_of_rows)