0.0.1 init, main page prepare
This commit is contained in:
41
BaseModels/search_optimization/ld_json/ld_article_news.py
Normal file
41
BaseModels/search_optimization/ld_json/ld_article_news.py
Normal file
@@ -0,0 +1,41 @@
|
||||
|
||||
import json
|
||||
|
||||
import project_sets
|
||||
from project_sets import *
|
||||
from django.urls import reverse
|
||||
from django.utils.html import strip_tags
|
||||
|
||||
def get_ld_article_news(art_name, art_txt, art_DT, url_data):
|
||||
from BaseModels.inter import get_all_photos_from_html_content
|
||||
|
||||
img_list = get_all_photos_from_html_content(art_txt)
|
||||
if img_list:
|
||||
img_list = list(map(lambda img: "{0}{1}".format(project_sets.domain, img), img_list))
|
||||
|
||||
data = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "NewsArticle",
|
||||
"url": "{0}{1}".format(project_sets.domain, reverse(**url_data)),
|
||||
"publisher":{
|
||||
"@type":"Organization",
|
||||
"name": project_sets.company_name,
|
||||
"logo": project_sets.logo
|
||||
},
|
||||
"author": {
|
||||
"@type": "Organization",
|
||||
"name": project_sets.company_name,
|
||||
"logo": project_sets.logo,
|
||||
"url": project_sets.domain,
|
||||
},
|
||||
"headline": art_name,
|
||||
# "mainEntityOfPage": "http://www.bbc.com/news/world-us-canada-39324587", # ссылка на источник
|
||||
"articleBody": strip_tags(art_txt),
|
||||
"datePublished": art_DT.isoformat()
|
||||
}
|
||||
if img_list:
|
||||
data.update({
|
||||
'image': img_list
|
||||
})
|
||||
|
||||
return json.dumps(data)
|
||||
Reference in New Issue
Block a user