Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from bs4 import BeautifulSoup
- import urllib2
- ukr = "http://www.ukrstat.gov.ua/operativ/operativ2013/rp/zn_ed_reg/zn_ed_reg_e/zn_ed_reg_2014k_e.htm"
- page = urllib2.urlopen(ukr)
- soup = BeautifulSoup(page)
- table = soup.find('table', id = "table2")
- NAM=[]
- TOT=[]
- AGR=[]
- IND=[]
- CON=[]
- TRA=[]
- STO=[]
- ACC=[]
- INF=[]
- FIN=[]
- for row in table.findAll("tr"):
- cells = row.findAll("td")
- if len(cells) == 10:
- NAM.append(cells[0].text.strip())
- TOT.append(cells[1].text.strip())
- AGR.append(cells[2].text.strip())
- IND.append(cells[3].text.strip())
- CON.append(cells[4].text.strip())
- TRA.append(cells[5].text.strip())
- STO.append(cells[6].text.strip())
- ACC.append(cells[7].text.strip())
- INF.append(cells[8].text.strip())
- FIN.append(cells[9].text.strip())
- print NAM
Add Comment
Please, Sign In to add comment