Fix all source Exception handling

This commit is contained in:
yoshiko2
2021-05-03 22:27:09 +08:00
parent c8e61936b3
commit 94c5598fde
3 changed files with 26 additions and 23 deletions

View File

@@ -99,6 +99,7 @@ def main(number):
web = get_html(result1)
soup = BeautifulSoup(web, 'lxml')
info = str(soup.find(attrs={'class': 'row movie'}))
try:
dic = {
'actor': getActor(web),
'title': getTitle(web).strip(getNum(web)),
@@ -119,6 +120,8 @@ def main(number):
'source': 'avsox.py',
'series': getSeries(info),
}
except:
dic = {"title": ""}
js = json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'), ) # .encode('UTF-8')
return js

View File

@@ -31,7 +31,7 @@ def main(number: str) -> json:
**data,
}
else:
dic = {}
dic = {"title": ""}
return json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'))
@@ -59,7 +59,7 @@ def parse_info(soup: BeautifulSoup) -> dict:
"series": get_series(data_dic),
}
else:
return {}
return {"title": ""}
def get_bold_text(h: str) -> str:

View File

@@ -94,7 +94,7 @@ def main(number: str):
"series": '',
}
else:
dic = {}
dic = {"title": ""}
return json.dumps(dic, ensure_ascii=False, sort_keys=True, indent=4, separators=(',', ':'))