fix microdata multiple authors
This commit is contained in:
parent
64ced635cc
commit
7420b5ece9
|
@ -92,7 +92,10 @@ def parse_extruct(s, data):
|
||||||
if props['datePublished']:
|
if props['datePublished']:
|
||||||
s['date'] = props['datePublished']
|
s['date'] = props['datePublished']
|
||||||
if 'author' in props and props['author']:
|
if 'author' in props and props['author']:
|
||||||
|
if 'properties' in props['author']:
|
||||||
s['author'] = props['author']['properties']['name']
|
s['author'] = props['author']['properties']['name']
|
||||||
|
elif isinstance(props['author'], list):
|
||||||
|
s['author'] = props['author'][0]['properties']['name']
|
||||||
|
|
||||||
for ld in data['json-ld']:
|
for ld in data['json-ld']:
|
||||||
if '@type' in ld and ld['@type'] in ['Article', 'NewsArticle']:
|
if '@type' in ld and ld['@type'] in ['Article', 'NewsArticle']:
|
||||||
|
@ -104,7 +107,7 @@ def parse_extruct(s, data):
|
||||||
if 'author' in ld and ld['author']:
|
if 'author' in ld and ld['author']:
|
||||||
if 'name' in ld['author']:
|
if 'name' in ld['author']:
|
||||||
s['author'] = ld['author']['name']
|
s['author'] = ld['author']['name']
|
||||||
elif len(ld['author']):
|
elif isinstance(ld['author'], list):
|
||||||
s['author'] = ld['author'][0]['name']
|
s['author'] = ld['author'][0]['name']
|
||||||
if '@graph' in ld:
|
if '@graph' in ld:
|
||||||
for gld in ld['@graph']:
|
for gld in ld['@graph']:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user