update
This commit is contained in:
38
scrapeje.py
38
scrapeje.py
@@ -1,14 +1,12 @@
|
|||||||
import re
|
#IMPORTO MODULI
|
||||||
import os
|
#selenium: scraper | bs4: parser | re: regex | os: interazione con os
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.support.ui import WebDriverWait
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
#import requests
|
from bs4 import BeautifulSoup
|
||||||
#import cloudscraper
|
import re
|
||||||
#import json
|
import os
|
||||||
|
|
||||||
|
|
||||||
#Inizializzo liste
|
#Inizializzo liste
|
||||||
nome=[]
|
nome=[]
|
||||||
@@ -16,29 +14,28 @@ desc=[]
|
|||||||
npezzi=[]
|
npezzi=[]
|
||||||
prezzo=[]
|
prezzo=[]
|
||||||
prezzoN=[]
|
prezzoN=[]
|
||||||
scripto=[]
|
|
||||||
|
|
||||||
|
|
||||||
#INPUT
|
#INPUT
|
||||||
#prende l url della pagina justeat del ristorante in input
|
#prende l url della pagina justeat del ristorante in input
|
||||||
print ("\nesempio: https://www.justeat.it/restaurants-pizzeria-la-garganica-bologna/menu")
|
# print ("\nesempio: https://www.justeat.it/restaurants-pizzeria-la-garganica-bologna/menu")
|
||||||
restaurant_url = input('INSERISCI IL LINK DELLA PAGINA DEL RISTORANTE: ')
|
# restaurant_url = input('INSERISCI IL LINK DELLA PAGINA DEL RISTORANTE: ')
|
||||||
|
|
||||||
#PER DEBUG
|
#PER DEBUG
|
||||||
#restaurant_url = 'https://www.justeat.it/restaurants-pizzeria-del-mercato-bologna/menu'
|
# restaurant_url = 'https://www.justeat.it/restaurants-pizzeria-del-mercato-bologna/menu'
|
||||||
|
|
||||||
|
|
||||||
#SCRAPE
|
# #SCRAPE
|
||||||
driver = webdriver.Chrome()
|
# driver = webdriver.Chrome()
|
||||||
driver.get(restaurant_url)
|
# driver.get(restaurant_url)
|
||||||
|
|
||||||
wait = WebDriverWait(driver, 10)
|
# wait = WebDriverWait(driver, 10)
|
||||||
wait.until(EC.presence_of_element_located((By.CLASS_NAME, "c-menuItems-price--offline")))
|
# wait.until(EC.presence_of_element_located((By.CLASS_NAME, "c-menuItems-price--offline")))
|
||||||
|
|
||||||
page = driver.page_source
|
# page = driver.page_source
|
||||||
|
|
||||||
with open('JEmenu.html', 'w') as f:
|
# with open('JEmenu.html', 'w') as f:
|
||||||
f.write(page)
|
# f.write(page)
|
||||||
|
|
||||||
|
|
||||||
#PARSER
|
#PARSER
|
||||||
@@ -195,6 +192,7 @@ for i in range(len(prezzo)):
|
|||||||
# with open("pagina.html", "w") as file:
|
# with open("pagina.html", "w") as file:
|
||||||
# file.write(html)
|
# file.write(html)
|
||||||
|
|
||||||
|
|
||||||
#Pulisce
|
#Pulisce
|
||||||
#ToDo:PROPORRE DI SALVARE IN RUBRICA
|
#ToDo:PROPORRE DI SALVARE IN RUBRICA
|
||||||
os.remove("JEmenu.html")
|
#os.remove("JEmenu.html")
|
||||||
Reference in New Issue
Block a user