30 lines
791 B
Python
30 lines
791 B
Python
#!/usr/bin/env python3
|
|
import itertools
|
|
import re
|
|
from urllib.request import urlopen
|
|
i = 0
|
|
f = open('bmw_opinie_oceny.txt', 'w')
|
|
ocena_new = []
|
|
|
|
f = open('bmw_opinie_oceny.txt', 'a')
|
|
url_bmw = 'https://www.motofakty.pl/samochody/opinie/bmw/'
|
|
|
|
|
|
|
|
for x in range(1,43):
|
|
strona = url_bmw + str(x) + '.html#lista-opinii'
|
|
html = urlopen(strona).read().decode('utf-8')
|
|
paragraphs = re.findall(r'<h4>Ocena:(.*?)</h4>',str(html))
|
|
opinia = re.findall(r'<p><b>Podsumowanie:</b>(.*?)</p>',str(html), re.MULTILINE|re.DOTALL)
|
|
for ocena in paragraphs:
|
|
ocena = ocena.replace(',','.')
|
|
ocena = ocena_new.append(ocena)
|
|
for opinie in opinia:
|
|
print('refyfyfy', ocena_new[i],'\n',opinie,'\n', file=f)
|
|
i += 1
|
|
|
|
|
|
|
|
f.close()
|
|
print ('liczba ocen: ', i)
|