small fixes + non infinte loading on error

This commit is contained in:
Askill 2020-04-22 20:23:18 +02:00
parent 4cad0e2e90
commit cb9b8183e6
5 changed files with 27 additions and 16 deletions

View File

@ -1,6 +1,8 @@
FROM python FROM python
COPY ./ /app COPY ./requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt RUN pip install -r /app/requirements.txt
COPY ./ /app
CMD python /app/run.py CMD python /app/run.py

Binary file not shown.

View File

@ -17,7 +17,11 @@ function loadData() {
renderRecipeList(data) renderRecipeList(data)
}, },
loadData() function (error, data) {
console.log(error)
rl.innerHTML = "<p>Es gab einen Fehler, bitte suchen Sie erneut.</p>"
}
); );
} }

View File

@ -42,7 +42,7 @@ def getImages():
if defaultImg == recipe.img: if defaultImg == recipe.img:
url = recipe.url url = recipe.url
string1 = '//*[@id="recipe-image-carousel"]/div/div[1]/div[10]/div/a/amp-img' string1 = '//*[@id="recipe-image-carousel"]/div/div[1]/div[10]/div/a/amp-img'
//*[@id="recipe-image-carousel"]/div/div[1]/div/div/a/amp-img
driver.get(url) driver.get(url)
element = WebDriverWait(driver, 30).until( element = WebDriverWait(driver, 30).until(
ec.presence_of_element_located(( ec.presence_of_element_located((
@ -63,11 +63,11 @@ def getImages():
counter +=1 counter +=1
print(counter/maxC) print(counter/maxC)
sleep(5) sleep(5)
except: except Exception as e:
errorUrls.append(recipe.url) errorUrls.append(recipe.url)
print(recipe.url) print(recipe.url)
print("error") print(e)
print(errorUrls)
getImages() getImages()

View File

@ -6,16 +6,21 @@ from nltk.corpus import stopwords
from application.db import Session, Recipe, Ingredient, Trunk from application.db import Session, Recipe, Ingredient, Trunk
def stemWord(word): def stemWord(word):
arr = [] try:
stopset = set(stopwords.words('german')) arr = []
stopset |= set("(),") stopset = set(stopwords.words('german'))
snowball = nltk.SnowballStemmer(language='german') stopset |= set("(),")
for token in nltk.word_tokenize(word): snowball = nltk.SnowballStemmer(language='german')
if token in stopset or len(token) < 4: for token in nltk.word_tokenize(word):
continue if token in stopset or len(token) < 4:
stemmed = snowball.stem(token) continue
arr.append(stemmed) stemmed = snowball.stem(token)
return arr arr.append(stemmed)
if len(arr) == 0:
arr.append("")
return arr
except:
return [""]
def migrate(path): def migrate(path):
recs = "" recs = ""