1、简单实现
关联文件:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r’^index.html/$’,views.index),
url(r’^article/(?p\d+)-(?p\d+).html/$’,views.article)
]
url.py
title
过滤条件
{% if kwargs.article_type == 0 %}
全部
{% else %}
全部
{% endif %}
{% for row in article_type %}
{% if row.id == kwargs.article_type %}
{{ row.caption }}
{% else %}
{{ row.caption }}
{% endif %}
{% endfor %}
{% if kwargs.category == 0 %}
全部
{% else %}
全部
{% endif %}
{% for row in category %}
{% if row.id == kwargs.category %}
{{ row.caption }}
{% else %}
{{ row.caption }}
{% endif %}
{% endfor %}
查询结果
{% for row in articles %}
{{ row.id }}-{{ row.title }}——[{{ row.article_type.caption }}]-[{{ row.category.caption }}]
{% endfor %}
article.html
数据库结构:
from django.db import models
# create your models here.
class categoery(models.model):
caption = models.charfield(max_length=16)
class articletype(models.model):
caption = models.charfield(max_length=16)
class article(models.model):
title = models.charfield(max_length=32)
content = models.charfield(max_length=255)
category = models.foreignkey(categoery)
article_type = models.foreignkey(articletype)
处理文件:
from . import models
def article(request,*args,**kwargs):
search_dict = {}
for key,value in kwargs.items():
kwargs[key] = int(value) # 把字符类型转化为int类型 方便前端做if a == b 这样的比较
if value !=’0′:
search_dict[key] = value
articles = models.article.objects.filter(**search_dict) # 字典为空时表示搜索所有
article_type = models.articletype.objects.all()
category = models.categoery.objects.all()
return render(request,’article.html’,{‘articles’:articles,
‘article_type’:article_type,
‘category’:category ,
‘kwargs’:kwargs})
注:实现此功能并不难,最重要的是理清里面的思路;首先先要确定url访问路径格式http://127.0.0.1:8000/article/0-0.html ,第一个0表示article_type字段,第二个0表示category字段,如果为零时,表示搜索此字段全部信息,确认好这个,是成功的第一步,处理文件上有检索的处理;第二个关键点是生成字典search_dict进行相关的搜索,如果是0表示搜索全部;第三个关键点,也是很巧妙的一个方式,把参数kwargs再次传到前端,简直神来之笔!
2、另一种尝试(加载内存调优)
由于articletype类型是博客定死的数据,后期不会做变动,可以把数据加载到内存当中,加快查询速度
title
过滤条件
{% if kwargs.article_type_id == 0 %}
全部
{% else %}
全部
{% endif %}
{% for row in article_type%}
{% if row.0 == kwargs.article_type_id %}
{{ row.1 }}
{% else %}
{{ row.1 }}
{% endif %}
{% endfor %}
{% if kwargs.category_id == 0 %}
全部
{% else %}
全部
{% endif %}
{% for row in category %}
{% if row.id == kwargs.category_id %}
{{ row.caption }}
{% else %}
{{ row.caption }}
{% endif %}
{% endfor %}
查询结果
{% for row in articles %}
{{ row.id }}-{{ row.title }}——[{{ row.article_type }}]-[{{ row.category.caption }}]
{% endfor %}
article.htmlfrom django.shortcuts import render
from django.shortcuts import httpresponse
# create your views here.
def index(request):
return httpresponse(‘ok’)
from . import models
def article(request,*args,**kwargs):
search_dict = {}
for key,value in kwargs.items():
kwargs[key] = int(value) # 把字符类型转化为int类型 方便前端做if a == b 这样的比较
if value !=’0′:
search_dict[key] = value
print(kwargs)
articles = models.article.objects.filter(**search_dict) # 字典为空时表示搜索所有
article_type = models.article.type_choice
print(article_type)
category = models.categoery.objects.all()
return render(request,’article.html’,{‘articles’:articles,
‘article_type’:article_type,
‘category’:category ,
‘kwargs’:kwargs})
处理文件.py
数据库文件:
from django.db import models
# create your models here.
class categoery(models.model):
caption = models.charfield(max_length=16)
# class articletype(models.model):
# caption = models.charfield(max_length=16)
class article(models.model):
title = models.charfield(max_length=32)
content = models.charfield(max_length=255)
category = models.foreignkey(categoery)
# article_type = models.foreignkey(articletype)
type_choice = [
(1,’python’),
(2,’linux’),
(3,’大数据’),
(4,’架构’),
]
article_type_id = models.integerfield(choices=type_choice)
3、利用simple_tag把代码优化
关联文件:
from django.db import models
# create your models here.
class categoery(models.model):
caption = models.charfield(max_length=16)
class articletype(models.model):
caption = models.charfield(max_length=16)
class article(models.model):
title = models.charfield(max_length=32)
content = models.charfield(max_length=255)
category = models.foreignkey(categoery)
article_type = models.foreignkey(articletype)
# type_choice = [
# (1,’python’),
# (2,’linux’),
# (3,’大数据’),
# (4,’架构’),
# ]
# article_type_id = models.integerfield(choices=type_choice)
数据库文件.pyfrom django.shortcuts import render
from django.shortcuts import httpresponse
# create your views here.
def index(request):
return httpresponse(‘ok’)
from . import models
def article(request, *args, **kwargs):
search_dict = {}
for key, value in kwargs.items():
kwargs[key] = int(value) # 把字符类型转化为int类型 方便前端做if a == b 这样的比较
if value != ‘0’:
search_dict[key] = value
articles = models.article.objects.filter(**search_dict) # 字典为空时表示搜索所有
article_type = models.articletype.objects.all()
print(article_type)
category = models.categoery.objects.all()
return render(request, ‘article.html’, {‘articles’: articles,
‘article_type’: article_type,
‘category’: category,
‘kwargs’: kwargs})
处理文件.py{% load filter %}
title
过滤条件
{% filter_all kwargs ‘article_type’%}
{% filter_single article_type kwargs ‘article_type’%}
{% filter_all kwargs ‘category’%}
{% filter_single category kwargs ‘category’%}
查询结果
{% for row in articles %}
{{ row.id }}-{{ row.title }}——[{{ row.article_type.caption }}]-[{{ row.category.caption }}]
{% endfor %}
article.html
创建templatetags目录,在目录下创建filter.py文件:
from django import template
from django.utils.safestring import mark_safe
register = template.library()
@register.simple_tag
def filter_all(kwargs,type_str):
print(type_str)
if type_str == ‘article_type’:
if kwargs[‘article_type’] == 0:
tmp = ‘ 全部 ‘%(kwargs[‘category’])
else:
tmp = ‘ 全部 ‘%(kwargs[‘category’])
elif type_str == ‘category’:
if kwargs[‘category’] == 0:
tmp = ‘ 全部 ‘ % (kwargs[‘article_type’])
else:
tmp = ‘ 全部 ‘ % (kwargs[‘article_type’])
return mark_safe(tmp)
@register.simple_tag()
def filter_single(type_obj,kwargs,type_str):
print(type_str)
tmp = ”
if type_str == ‘article_type’:
for row in type_obj:
if row.id == kwargs[‘article_type’]:
tag = ‘%s\n’%(row.id,kwargs[‘category’],row.caption)
else:
tag = ‘%s\n’ % (row.id, kwargs[‘category’],row.caption)
tmp +=tag
elif type_str == ‘category’:
for row in type_obj:
if row.id == kwargs[‘category’]:
tag = ‘%s\n’ % (kwargs[‘article_type’],row.id, row.caption)
else:
tag = ‘%s\n’ % (kwargs[‘article_type’], row.id, row.caption)
tmp += tag
return mark_safe(tmp)
html文件主体内容:
{% load filter %}
过滤条件
{% filter_all kwargs ‘article_type’%}
{% filter_single article_type kwargs ‘article_type’%}
{% filter_all kwargs ‘category’%}
{% filter_single category kwargs ‘category’%}
查询结果
{% for row in articles %}
{{ row.id }}-{{ row.title }}——[{{ row.article_type.caption }}]-[{{ row.category.caption }}]
{% endfor %}
jsonp
jsonp(json with padding)是json的一种“使用模式”,可用于解决主流浏览器的跨域数据访问的问题。由于同源策略,一般来说位于 server1.example.com 的网页无法与不是 server1.example.com的服务器沟通,而 html 的《script》 元素是一个例外。利用 《script》 元素的这个开放策略,网页可以得到从其他来源动态产生的 json 资料,而这种使用模式就是所谓的 jsonp。用 jsonp 抓到的资料并不是 json,而是任意的javascript,用 javascript 直译器执行而不是用 json 解析器解析。
原理:
– 创建script标签
– src=远程地址
– 返回的数据必须是js格式
– 只能发get请求
1、什么是同源策略?
处理文件:
import requests
def jsonp(request):
# 获取url信息
response = requests.get(‘http://weatherapi.market.xiaomi.com/wtr-v2/weather?city)
response.encoding = ‘utf-8′ # 进行编码
return render(request,’jsonp.html’,{‘result’:response.text}) # response.text 请求内容
html文件:
后台获取的结果
{{ result }}
js直接获取结果
《script》
《script》
function getcontent() {
var xhr = new xmlhttprequest(); // 创建对象
xhr.open(‘get’, ‘http://weatherapi.market.xiaomi.com/wtr-v2/weather?city); // get方式打开
xhr.onreadystatechange = function () { // 收到返回值时执行
console.log(xhr.responsetext);
};
xhr.send() // 发送
}
《script》
注:点击js直接获取结果时,浏览器显示下面报错信息,由于浏览器只接受http://127.0.0.1:8000发过来的信息,对于天气网站发过来的信息直接屏蔽掉了,这就是同源策略,那有没有什么方式可以解决?
xmlhttprequest cannot load http://weatherapi.market.xiaomi.com/wtr-v2/weather?cityaccess-control-allow-origin’ header is present on the requested resource. origin ‘http://127.0.0.1:8000’ is therefore not allowed access.
2、巧用script标签src属性
script标签不受同源策略的影响
处理文件:
import requests
def jsonp(request):
# 获取url信息
response = requests.get(‘http://weatherapi.market.xiaomi.com/wtr-v2/weather?city)
response.encoding = ‘utf-8′ # 进行编码
return render(request,’jsonp.html’,{‘result’:response.text}) # response.text 请求内容
def jsonp_api(request):
return httpresponse(‘alert(123)’)
html文件:
后台获取的结果
{{ result }}
js直接获取结果
《script》
function getcontent() {
var tag = document.createelement(‘script’);
tag.src = ‘/jsonp_api.html’;
document.head.appendchild(tag);
// document.head.removechild(tag);
}
《script》
注:js请求时为了方便,还是请求的是当前程序url;执行完上面代码会发现一个神奇的状况,页面会弹出123信息,表明script获取信息成功
3、对前后端稍加改造,使用方法更加动态化
处理文件:
def jsonp(request):
return render(request,’jsonp.html’) # response.text 请求内容
def jsonp_api(request):
func = request.get.get(‘callback’) # 获取用户callback参数
content = ‘%s(10000)’%func # 执行func(10000)函数
return httpresponse(content)
html文件:
后台获取的结果
{{ result }}
js直接获取结果
《script》
function getcontent() {
var tag = document.createelement(‘script’);
tag.src = ‘/jsonp_api.html?callback=list’; // 自定义callback参数,与后台达成默契
document.head.appendchild(tag);
// document.head.removechild(tag);
}
function list(arg){ // 自定义函数与callback=list相对应
alert(arg);
}
《script》
注:js发请求时,带上callback参数,然后定义参数对应的方法,后台会把数据传入此方法内并且执行执行;至于要打印还是弹框,就看用户自己的需求去处理了;jsonp的原理和实现过程就是上述代码的实现
4、实例应用+ajax
处理文件:
import requests
def jsonp(request):
response = requests.get(‘http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=1454376870403’)
response.encoding = ‘utf-8’ # 进行编码
return render(request, ‘jsonp.html’, {‘result’: response.text}) # response.text 请求内容
html文件:
后台获取的结果
{{ result }}
js直接获取结果
《script》
《script》
function getcontent() {
$.ajax({
url: ‘http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=1454376870403’,
type: ‘post’,
datatype: ‘jsonp’, // 即使写的type是post也是按照get请求发送
jsonp: ‘callback’,
jsonpcallback: ‘list’
});
}
function list(arg){ // 自定义函数与callback=list相对应
console.log(arg);
var data = arg[‘data’];
for(k in data){
var tr = document.createelement(‘td’);
var week = data[k][‘week’];
var list = data[k][‘list’];
tr.textcontent =week
document.body.appendchild(tr);
console.log(week);
for(i in list){
var name = list[i][‘name’];
console.log(name)
}}}
《script》
list({data:[ { “week”:”周日”, “list”:[ { “time”:”0030″, “name”:”通宵剧场六集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0530″, “name”:”《都市现场》60分钟精编版(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0630″, “name”:”《快乐生活一点通》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0700″, “name”:”《e早晨报》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0800″, “name”:”精选剧场四集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1120″, “name”:”《地宝当家》(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1200″, “name”:”《都市60分》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1300″, “name”:”《谁是赢家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1400″, “name”:”女性剧场三集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1700″, “name”:”《快乐生活一点通》精编版”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1730″, “name”:”《地宝当家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1800″, “name”:”《都市现场》90分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1930″, “name”:”《都市情缘》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2000″, “name”:”《晚间800》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2020″, “name”:”《都市剧场》黄金剧(第1集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2110″, “name”:”《都市剧场》黄金剧(第2集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2200″, “name”:”《拍案》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2230″, “name”:”江西新闻联播(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2250″, “name”:”都市晚剧场”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” } ] }, { “week”:”周一”, “list”:[ { “time”:”0030″, “name”:”通宵剧场六集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0530″, “name”:”《都市现场》60分钟精编版(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0630″, “name”:”《快乐生活一点通》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0700″, “name”:”《e早晨报》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0800″, “name”:”精选剧场四集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1120″, “name”:”《地宝当家》(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1200″, “name”:”《都市60分》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1300″, “name”:”《谁是赢家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1400″, “name”:”女性剧场三集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1700″, “name”:”《快乐生活一点通》精编版”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1730″, “name”:”《地宝当家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1800″, “name”:”《都市现场》90分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1930″, “name”:”《都市情缘》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2000″, “name”:”《晚间800》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2020″, “name”:”《都市剧场》黄金剧(第1集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2110″, “name”:”《都市剧场》黄金剧(第2集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2200″, “name”:”《拍案》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2230″, “name”:”江西新闻联播(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2250″, “name”:”都市晚剧场”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” } ] },{ “week”:”周二”, “list”:[ { “time”:”0030″, “name”:”通宵剧场六集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0530″, “name”:”《都市现场》60分钟精编版(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0630″, “name”:”《快乐生活一点通》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0700″, “name”:”《e早晨报》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0800″, “name”:”精选剧场四集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1120″, “name”:”《地宝当家》(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1200″, “name”:”《都市60分》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1300″, “name”:”《谁是赢家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1400″, “name”:”女性剧场三集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1700″, “name”:”《快乐生活一点通》精编版”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1730″, “name”:”《地宝当家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1800″, “name”:”《都市现场》90分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1930″, “name”:”《都市情缘》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2000″, “name”:”《晚间800》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2020″, “name”:”《都市剧场》黄金剧(第1集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2110″, “name”:”《都市剧场》黄金剧(第2集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2200″, “name”:”《拍案》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2230″, “name”:”江西新闻联播(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2250″, “name”:”都市晚剧场”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” } ] },{ “week”:”周三”, “list”:[ { “time”:”0030″, “name”:”通宵剧场六集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0530″, “name”:”《都市现场》60分钟精编版(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0630″, “name”:”《快乐生活一点通》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0700″, “name”:”《e早晨报》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0800″, “name”:”精选剧场四集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1120″, “name”:”《地宝当家》(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1200″, “name”:”《都市60分》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1300″, “name”:”《谁是赢家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1400″, “name”:”女性剧场三集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1700″, “name”:”《快乐生活一点通》精编版”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1730″, “name”:”《地宝当家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1800″, “name”:”《都市现场》90分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1930″, “name”:”《都市情缘》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2000″, “name”:”《晚间800》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2020″, “name”:”《都市剧场》黄金剧(第1集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2110″, “name”:”《都市剧场》黄金剧(第2集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2200″, “name”:”《拍案》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2230″, “name”:”江西新闻联播(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2250″, “name”:”都市晚剧场”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” } ] },{ “week”:”周四”, “list”:[ { “time”:”0030″, “name”:”通宵剧场六集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0530″, “name”:”《都市现场》60分钟精编版(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0630″, “name”:”《快乐生活一点通》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0700″, “name”:”《e早晨报》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0800″, “name”:”精选剧场四集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1120″, “name”:”《地宝当家》(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1200″, “name”:”《都市60分》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1300″, “name”:”《谁是赢家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1400″, “name”:”女性剧场三集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1700″, “name”:”《快乐生活一点通》精编版”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1730″, “name”:”《地宝当家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1800″, “name”:”《都市现场》90分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1930″, “name”:”《都市情缘》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2000″, “name”:”《晚间800》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2020″, “name”:”《都市剧场》黄金剧(第1集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2110″, “name”:”《都市剧场》黄金剧(第2集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2200″, “name”:”《拍案》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2230″, “name”:”江西新闻联播(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2250″, “name”:”都市晚剧场”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” } ] },{ “week”:”周五”, “list”:[ { “time”:”0030″, “name”:”通宵剧场六集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0530″, “name”:”《都市现场》60分钟精编版(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0630″, “name”:”《快乐生活一点通》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0700″, “name”:”《e早晨报》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0800″, “name”:”精选剧场四集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1120″, “name”:”《地宝当家》(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1200″, “name”:”《都市60分》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1300″, “name”:”《谁是赢家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1400″, “name”:”女性剧场三集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1700″, “name”:”《快乐生活一点通》精编版”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1730″, “name”:”《地宝当家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1800″, “name”:”《都市现场》90分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1930″, “name”:”《都市情缘》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2000″, “name”:”《晚间800》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2020″, “name”:”《都市剧场》黄金剧(第1集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2110″, “name”:”《都市剧场》黄金剧(第2集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2200″, “name”:”《拍案》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2230″, “name”:”江西新闻联播(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2250″, “name”:”都市晚剧场”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” } ] },{ “week”:”周六”, “list”:[ { “time”:”0030″, “name”:”通宵剧场六集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0530″, “name”:”《都市现场》60分钟精编版(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0630″, “name”:”《快乐生活一点通》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0700″, “name”:”《e早晨报》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”0800″, “name”:”精选剧场四集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1120″, “name”:”《地宝当家》(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1200″, “name”:”《都市60分》60分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1300″, “name”:”《谁是赢家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1400″, “name”:”女性剧场三集连播”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1700″, “name”:”《快乐生活一点通》精编版”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1730″, “name”:”《地宝当家》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1800″, “name”:”《都市现场》90分钟直播版块”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”1930″, “name”:”《都市情缘》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2000″, “name”:”《晚间800》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2020″, “name”:”《都市剧场》黄金剧(第1集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2110″, “name”:”《都市剧场》黄金剧(第2集)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2200″, “name”:”《拍案》”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2230″, “name”:”江西新闻联播(重播)”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” }, { “time”:”2250″, “name”:”都市晚剧场”, “link”:”http://www.jxntv.cn/live/jxtv2.shtml” } ] }] });
注:实现的过程跟第3自己写的代码一毛一样,也是创建个script然后再删除
更多python开发【django】:组合搜索、jsonp、xss过滤相关文章请关注php中文网!