55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
import itertools
|
|
import re
|
|
from urllib.request import urlopen
|
|
i = 0
|
|
f = open('auto_opinie_oceny.txt', 'w')
|
|
ocena_new = []
|
|
|
|
f = open('auto_opinie_oceny.txt', 'a')
|
|
url_skoda = 'https://www.motofakty.pl/samochody/opinie/skoda/'
|
|
url_audi = 'https://www.motofakty.pl/samochody/opinie/audi/'
|
|
url_citroen = 'https://www.motofakty.pl/samochody/opinie/citroen/'
|
|
|
|
|
|
|
|
for x in range(1,120):
|
|
strona = url_skoda + 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
|
|
|
|
for x in range(1,120):
|
|
strona = url_audi + 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_new.append(ocena)
|
|
for opinie in opinia:
|
|
print('refyfyfy', ocena_new[i],'\n',opinie,'\n', file=f)
|
|
i += 1
|
|
for x in range(1,120):
|
|
strona = url_citroen + 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)
|
|
|