24 Star 119 Fork 0

biancangming / bianbingdang

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
site_maps.py 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
biancangming 提交于 2019-11-16 11:01 . 升级编辑器,等若干
#!usr/bin/env python
# -*- coding:utf-8 -*-
"""
@author:'手机视界'
@file: site_maps.py
@time: 2018/12/11
site_map配置页面
"""
import requests
import json
from django.contrib.sitemaps import GenericSitemap
from article_manager.models import Article
from bbd_admin.models import SiteSetting
article_dict = {
'queryset': Article.objects.filter(delete=False, hide=False),
'date_field': 'update_time',
}
sitemaps = {
# 'flatpages': FlatPageSitemap,
'article': GenericSitemap(article_dict, priority=0.8),
}
def post_urls_to_baidu(data):
"""
向百度主动推送链接
data 'url1\nurl2\n.....'
:return:
"""
to = ""
site_setting = SiteSetting.objects.first()
if site_setting:
to = site_setting.push_url
headers = {
'User - Agent': 'curl / 7.12.1',
'Host': 'data.zz.baidu.com',
'Content - Type': 'text / plain',
'Content - Length': '83',
}
resp = requests.post(to, headers=headers, data=data)
return json.loads(resp.content.decode('utf8'))
# if __name__ == '__main__':
# post_urls_to_baidu('http://bianbingdang.com/article_detail/104.html')
Python
1
https://gitee.com/bsxbl/bianbingdang.git
git@gitee.com:bsxbl/bianbingdang.git
bsxbl
bianbingdang
bianbingdang
master

搜索帮助