Update 'ScrapeJE.py'
This commit is contained in:
27
ScrapeJE.py
27
ScrapeJE.py
@@ -8,17 +8,21 @@ npezzi=[]
|
||||
prezzo=[]
|
||||
n=0
|
||||
|
||||
linkJE = input('Incolla il link del ristorante: ')
|
||||
linkJE
|
||||
#prende l url della pagina justeat del ristorante in input
|
||||
linkJE = input('link della pagina justeat del ristorante: ')
|
||||
|
||||
#scrape html
|
||||
scraper = cloudscraper.create_scraper(browser={'browser': 'firefox','platform': 'windows','mobile': False})
|
||||
page = scraper.get(linkJE).content
|
||||
#crea il file html
|
||||
with open('aleppo.html', 'wb') as f:
|
||||
f.write(page)
|
||||
|
||||
#apre e legge il file
|
||||
with open('aleppo.html', 'rb') as f:
|
||||
page = f.read()
|
||||
|
||||
#parser
|
||||
soup = BeautifulSoup(page, "html.parser")
|
||||
menu = soup.find(attrs={"data-test-id": "menu-item"})
|
||||
|
||||
@@ -27,8 +31,15 @@ menu = soup.find(attrs={"data-test-id": "menu-item"})
|
||||
nrist=soup.title.text[8:-32]
|
||||
menu.find(attrs={"allergenPhoneNumber": "menu-item-name"})
|
||||
|
||||
# alla riga 870 dell html c'è "allergenPhoneNumber":"3389529446"
|
||||
|
||||
##
|
||||
#Stora il numero di telfono del ristorante
|
||||
#info-> alla riga 870 dell html, all interno di uno <script> c'è il numero in forma-> "allergenPhoneNumber":"3389529446" (riferio alì qaundo si scrapa aleppo)
|
||||
#tel=
|
||||
##
|
||||
|
||||
|
||||
#cicla le schede prodotto
|
||||
for menu in soup.find_all(attrs={"data-test-id": "menu-item"}):
|
||||
att=menu
|
||||
#riempie la lista "nome"
|
||||
@@ -48,7 +59,7 @@ for menu in soup.find_all(attrs={"data-test-id": "menu-item"}):
|
||||
for att in menu.find("p", class_="c-menuItems-price notranslate"):
|
||||
prezzo.append(att.lstrip().splitlines()[0])
|
||||
|
||||
# #riempie la lista "npezzi"
|
||||
#riempie la lista "npezzi"
|
||||
att=menu.find_all(attrs={"data-test-id": "menu-item-description"})
|
||||
if att != None:
|
||||
if menu.text.find("pezzo") > 0 or menu.text.find("pezzi") > 0:
|
||||
@@ -65,15 +76,19 @@ for x in range(len(nome)):
|
||||
print(npezzi[x])
|
||||
print(prezzo[x])
|
||||
|
||||
#stampa lunghezza liste del risrorante
|
||||
#stampa lunghezza liste e nome del risrorante # e numero di telefono
|
||||
print("\n")
|
||||
print(nrist)
|
||||
#print(tel)
|
||||
print("lista nome",len(nome),)
|
||||
print("lista desc:",len(desc))
|
||||
print("lista npezzi:",len(npezzi))
|
||||
print("lista prezzi:",len(prezzo)) #da trattare come stringa perchè ci sono anche i es. "da 1,00 €"
|
||||
print("lista prezzi:",len(prezzo)) #da trattare come stringa perchè ci sono anche prezzi come es. "da 1,00 €" (da formattare formattare int per fare i conti)
|
||||
|
||||
|
||||
#
|
||||
#Creare un file json formattato per jawanndenn
|
||||
#automatizzare l inserimento in jawandenn
|
||||
#jawanndenn include la funzione per argomento
|
||||
#"jawanndenn --loaddata FILE.json" --> Load a JSON export of the database from FILE.json, then quit.
|
||||
#
|
||||
Reference in New Issue
Block a user