add handling of missing urls
This commit is contained in:
@@ -45,19 +45,22 @@ if __name__ == '__main__':
|
|||||||
log.info(f"{item['id']} - {str(link)}")
|
log.info(f"{item['id']} - {str(link)}")
|
||||||
if not link:
|
if not link:
|
||||||
continue
|
continue
|
||||||
try:
|
if link == "None":
|
||||||
r = requests.get(link)
|
item['url'] = None
|
||||||
soup = BeautifulSoup(r.content, "html.parser")
|
else:
|
||||||
title_tag = soup.find('title')
|
try:
|
||||||
if title_tag:
|
r = requests.get(link)
|
||||||
title= title_tag.get_text()
|
soup = BeautifulSoup(r.content, "html.parser")
|
||||||
title = soup.title.string
|
title_tag = soup.find('title')
|
||||||
item['title'] = title
|
if title_tag:
|
||||||
item['review'] = False
|
title= title_tag.get_text()
|
||||||
except Exception as error:
|
title = soup.title.string
|
||||||
log.info(f"something went wrong: {error}")
|
item['title'] = title
|
||||||
item['title'] = None
|
item['review'] = False
|
||||||
item['review'] = True
|
except Exception as error:
|
||||||
|
log.info(f"something went wrong: {error}")
|
||||||
|
item['title'] = None
|
||||||
|
item['review'] = True
|
||||||
update = requests.put(f"http://127.0.0.1:8800/api/media/files/{item['id']}", json=item)
|
update = requests.put(f"http://127.0.0.1:8800/api/media/files/{item['id']}", json=item)
|
||||||
log.info(f"update status: {update.status_code}")
|
log.info(f"update status: {update.status_code}")
|
||||||
log.info(f"update result: {update.json()}")
|
log.info(f"update result: {update.json()}")
|
||||||
|
|||||||
Reference in New Issue
Block a user