fix minor scrape bug & update log
This commit is contained in:
parent
a0562c5e59
commit
b9b0c6be4e
3 changed files with 4 additions and 3 deletions
|
@ -196,8 +196,8 @@ def retrieve(request, id):
|
|||
}
|
||||
)
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
logger.warning('non-GET method at /book/<id>')
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
|
@ -47,6 +47,7 @@ def log_url(func):
|
|||
except Exception as e:
|
||||
# log the url
|
||||
logger.error(f"Scrape Failed URL: {args[0]}")
|
||||
logger.error(str(e))
|
||||
raise e
|
||||
|
||||
return wrapper
|
||||
|
@ -115,7 +116,7 @@ def scrape_douban_book(url):
|
|||
|
||||
# parsing starts here
|
||||
try:
|
||||
title = content.xpath("/html/body/div[3]/h1/span/text()")[0].strip()
|
||||
title = content.xpath("/html/body//h1/span/text()")[0].strip()
|
||||
except IndexError:
|
||||
raise ValueError("given url contains no book info")
|
||||
|
||||
|
|
|
@ -198,8 +198,8 @@ def retrieve(request, id):
|
|||
}
|
||||
)
|
||||
else:
|
||||
return HttpResponseBadRequest()
|
||||
logger.warning('non-GET method at /movie/<id>')
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Add table
Reference in a new issue