fix issue when no synopsys div
This commit is contained in:
parent
9bf2b5a97d
commit
2256435c3f
@ -24,14 +24,22 @@ def parse_emmission(strsearch):
|
|||||||
html = response.read()
|
html = response.read()
|
||||||
parse=BeautifulSoup(html,"html.parser")
|
parse=BeautifulSoup(html,"html.parser")
|
||||||
divcasting=parse.select_one(".descriptif")
|
divcasting=parse.select_one(".descriptif")
|
||||||
casting=divcasting.find_all(href=re.compile("biographie"))
|
if (divcasting):
|
||||||
count=0
|
casting=divcasting.find_all(href=re.compile("biographie"))
|
||||||
for actor in casting:
|
count=0
|
||||||
casting[count]=actor.text
|
for actor in casting:
|
||||||
count+=1
|
casting[count]=actor.text
|
||||||
|
count+=1
|
||||||
|
else:
|
||||||
|
casting= None
|
||||||
divsynopsis=parse.select_one(".episode-synopsis")
|
divsynopsis=parse.select_one(".episode-synopsis")
|
||||||
img=divsynopsis.find_next('img')['data-src']
|
if (divsynopsis):
|
||||||
synopsis=divsynopsis.select_one(".d-b").text
|
img=divsynopsis.find_next('img')['data-src']
|
||||||
|
synopsis=divsynopsis.select_one(".d-b").text
|
||||||
|
else:
|
||||||
|
img=None
|
||||||
|
synopsis=""
|
||||||
|
|
||||||
return {'title':link['title'],'href':href,'casting':casting,'synopsis':remove_first_space(synopsis),'img':img}
|
return {'title':link['title'],'href':href,'casting':casting,'synopsis':remove_first_space(synopsis),'img':img}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user