brandizzi

Untitled

Aug 1st, 2016
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. from bs4 import BeautifulSoup
  3. import urllib2
  4.  
  5. ukr = "http://www.ukrstat.gov.ua/operativ/operativ2013/rp/zn_ed_reg/zn_ed_reg_e/zn_ed_reg_2014k_e.htm"
  6. page = urllib2.urlopen(ukr)
  7. soup = BeautifulSoup(page)
  8. table = soup.find('table', id = "table2")
  9.  
  10. NAM=[]
  11. TOT=[]
  12. AGR=[]
  13. IND=[]
  14. CON=[]
  15. TRA=[]
  16. STO=[]
  17. ACC=[]
  18. INF=[]
  19. FIN=[]
  20.  
  21. for row in table.findAll("tr"):
  22.     cells = row.findAll("td")
  23.     if len(cells) == 10:
  24.         NAM.append(cells[0].text.strip())
  25.         TOT.append(cells[1].text.strip())
  26.         AGR.append(cells[2].text.strip())
  27.         IND.append(cells[3].text.strip())
  28.         CON.append(cells[4].text.strip())
  29.         TRA.append(cells[5].text.strip())
  30.         STO.append(cells[6].text.strip())
  31.         ACC.append(cells[7].text.strip())
  32.         INF.append(cells[8].text.strip())
  33.         FIN.append(cells[9].text.strip())
  34.  
  35. print NAM
Add Comment
Please, Sign In to add comment