Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Megafon Detalize

Thesilverwolf Jun 19th, 2018 74 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import bs4, re
  2. res = open('./bill.html',encoding='utf-8')
  3. result = open('bill.csv',"w")
  4. bill = bs4.BeautifulSoup(res,"html.parser")
  5. allNum = bill.select("table")
  6. fileArray = ["Абонент;Услуга;Количество;Сумма\n"]
  7. for num in allNum:
  8.     pattern = re.compile(r's(\d){2}-([A-Z0-9]){32}')
  9.     numpatt = re.compile(r'(\d){11}')
  10.     items = num.findAll('td',{'class': pattern})
  11.     if len(items)>15:
  12.         for i in range(15,len(items)-3,3):
  13.             abonent = numpatt.search(items[9].getText())
  14.             if type(abonent) != type(None):
  15.                 row = abonent[0]+";"+items[i].getText()+";"+items[i+1].getText()+";"+items[i+2].getText()+"\n"
  16.                 fileArray.append(row)
  17.  
  18. for ab in fileArray:
  19.     result.write(ab)
  20. result.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top