update
This commit is contained in:
46
scrapeje.py
46
scrapeje.py
@@ -9,6 +9,7 @@ import re
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
|
import time
|
||||||
|
|
||||||
restaurant_url=''
|
restaurant_url=''
|
||||||
driver=''
|
driver=''
|
||||||
@@ -37,13 +38,41 @@ def inputurl():
|
|||||||
#restaurant_url = 'https://www.justeat.it/restaurants-pizzeriadelrondone-bologna/menu'
|
#restaurant_url = 'https://www.justeat.it/restaurants-pizzeriadelrondone-bologna/menu'
|
||||||
|
|
||||||
|
|
||||||
|
def animazione():
|
||||||
|
def typewriter(text, delay=0.1):
|
||||||
|
for letter in text:
|
||||||
|
print(letter, end='', flush=True)
|
||||||
|
time.sleep(delay)
|
||||||
|
print()
|
||||||
|
|
||||||
|
typewriter("▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▁", 0.09)
|
||||||
|
|
||||||
|
|
||||||
def scraper():
|
def scraper():
|
||||||
global driver
|
global driver
|
||||||
global page
|
global page
|
||||||
global restaurant_url
|
global restaurant_url
|
||||||
driver = webdriver.Chrome()
|
|
||||||
|
#FIREFOX
|
||||||
|
opts = webdriver.FirefoxOptions()
|
||||||
|
opts.headless = True
|
||||||
|
driver = webdriver.Firefox(options=opts)
|
||||||
driver.get(restaurant_url)
|
driver.get(restaurant_url)
|
||||||
|
|
||||||
|
#CHROMIUM/CHROME
|
||||||
|
# driver = webdriver.Chrome()
|
||||||
|
# driver.get(restaurant_url)
|
||||||
|
|
||||||
|
animazione()
|
||||||
|
|
||||||
|
def typewriter(text, delay=0.1):
|
||||||
|
for letter in text:
|
||||||
|
print(letter, end='', flush=True)
|
||||||
|
time.sleep(delay)
|
||||||
|
print()
|
||||||
|
|
||||||
|
typewriter("▁ ▂ ▃ ▄ ▅ ▆ ▇ █ ▇ ▆ ▅ ▄ ▃ ▁", 0.09)
|
||||||
|
|
||||||
wait = WebDriverWait(driver, 16)
|
wait = WebDriverWait(driver, 16)
|
||||||
wait.until(EC.presence_of_element_located((By.CLASS_NAME, "c-menuItems-price")))
|
wait.until(EC.presence_of_element_located((By.CLASS_NAME, "c-menuItems-price")))
|
||||||
|
|
||||||
@@ -291,6 +320,7 @@ def salvainrubrica():
|
|||||||
os.remove("JEmenu.html")
|
os.remove("JEmenu.html")
|
||||||
os.remove("rubrica.txt")
|
os.remove("rubrica.txt")
|
||||||
os.remove("logo.gif")
|
os.remove("logo.gif")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#############################################################################################
|
#############################################################################################
|
||||||
@@ -300,13 +330,13 @@ def salvainrubrica():
|
|||||||
|
|
||||||
if os.path.exists('rubrica.txt') and os.path.exists('./DATI_RUBRICA'):
|
if os.path.exists('rubrica.txt') and os.path.exists('./DATI_RUBRICA'):
|
||||||
|
|
||||||
wr = input('\nVuoi vedere la rubrica? [Y|N] ')
|
#wr = input('\nVuoi vedere la rubrica? [Y|N] ')
|
||||||
#wr = 's'
|
wr = 's'
|
||||||
if wr.upper() in ['YES', 'Y', 'SI', 'S']:
|
if wr.upper() in ['YES', 'Y', 'SI', 'S']:
|
||||||
print( '\n', os.listdir('./DATI_RUBRICA'), '\n')
|
print( '\n', os.listdir('./DATI_RUBRICA'), '\n')
|
||||||
|
|
||||||
scelta = input("Scegli un numero esistente o premi Enter per metterre un link: ")
|
#scelta = input("Scegli un numero esistente o premi Enter per metterre un link: ")
|
||||||
#scelta = '1'
|
scelta = '1'
|
||||||
parserdarubrica()
|
parserdarubrica()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -328,10 +358,8 @@ genera_prezzoN()
|
|||||||
salvainrubrica()
|
salvainrubrica()
|
||||||
genera_frontend()
|
genera_frontend()
|
||||||
|
|
||||||
|
driver = webdriver.Firefox()
|
||||||
|
driver.get("file://" + os.path.abspath("pagina2.html"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,13 @@
|
|||||||
<body>
|
<body>
|
||||||
|
|
||||||
<body style="background-color: black; color: white">
|
<body style="background-color: black; color: white">
|
||||||
<h1 style='text-align: center; color: #ff8d1a'>{{ nrist }} </h1><br><br>
|
<h1 style='text-align: center; color: #ff8d1a'>{{ nrist }} </h1>
|
||||||
|
|
||||||
|
<!-- <form id="usernameForm">
|
||||||
|
<input type="text" id="prodottiAggiunti" placeholder="Enter your username" />
|
||||||
|
<button type="button" onclick="addUser()">Add User</button> -->
|
||||||
|
</form>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
{% for index in range(nome|length) %}
|
{% for index in range(nome|length) %}
|
||||||
@@ -39,5 +45,7 @@
|
|||||||
updateTotal();
|
updateTotal();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user