Update 'ScrapeJE.py'
This commit is contained in:
19
ScrapeJE.py
19
ScrapeJE.py
@@ -8,11 +8,13 @@ npezzi=[]
|
|||||||
prezzo=[]
|
prezzo=[]
|
||||||
n=0
|
n=0
|
||||||
|
|
||||||
|
linkJE = input('Incolla il link del ristorante: ')
|
||||||
|
linkJE
|
||||||
#scrape html
|
#scrape html
|
||||||
# scraper = cloudscraper.create_scraper(browser={'browser': 'firefox','platform': 'windows','mobile': False})
|
scraper = cloudscraper.create_scraper(browser={'browser': 'firefox','platform': 'windows','mobile': False})
|
||||||
# page = scraper.get("https://www.justeat.it/restaurants-saporedialeppo/menu").content
|
page = scraper.get(linkJE).content
|
||||||
# with open('aleppo.html', 'wb') as f:
|
with open('aleppo.html', 'wb') as f:
|
||||||
# f.write(page)
|
f.write(page)
|
||||||
|
|
||||||
with open('aleppo.html', 'rb') as f:
|
with open('aleppo.html', 'rb') as f:
|
||||||
page = f.read()
|
page = f.read()
|
||||||
@@ -22,7 +24,7 @@ menu = soup.find(attrs={"data-test-id": "menu-item"})
|
|||||||
|
|
||||||
|
|
||||||
#Stora nome ristorante
|
#Stora nome ristorante
|
||||||
nrist=soup.title.text[8:24]
|
nrist=soup.title.text[8:-32]
|
||||||
menu.find(attrs={"allergenPhoneNumber": "menu-item-name"})
|
menu.find(attrs={"allergenPhoneNumber": "menu-item-name"})
|
||||||
|
|
||||||
# alla riga 870 dell html c'è "allergenPhoneNumber":"3389529446"
|
# alla riga 870 dell html c'è "allergenPhoneNumber":"3389529446"
|
||||||
@@ -69,4 +71,9 @@ print(nrist)
|
|||||||
print("lista nome",len(nome),)
|
print("lista nome",len(nome),)
|
||||||
print("lista desc:",len(desc))
|
print("lista desc:",len(desc))
|
||||||
print("lista npezzi:",len(npezzi))
|
print("lista npezzi:",len(npezzi))
|
||||||
print("lista prezzi:",len(prezzo))
|
print("lista prezzi:",len(prezzo)) #da trattare come stringa perchè ci sono anche i es. "da 1,00 €"
|
||||||
|
|
||||||
|
#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