首頁  >  文章  >  後端開發  >  Python開發【Django】:組合搜尋、JSONP、XSS過濾

Python開發【Django】:組合搜尋、JSONP、XSS過濾

高洛峰
高洛峰原創
2017-02-22 10:37:521985瀏覽

1、簡單實作

關聯檔:

from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^index.html/$',views.index),
    url(r'^article/(?P47cf9185b9d6e565a16a5b103ea64946\d+)-(?Pc58a1130350e5f417b7f5c3a9765ab7e\d+).html/$',views.article)
]

url.py
76c82f278ac045591c9159d381de2c57
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
    a80eb7cbb6fff8b0ff70bae37074b813
    b2386ffb911b14667cb8f0f91ea547a7Title6e916e0f7d1e588d4f442bf645aedb2f
    c9ccee2e6ea535a969eb3f532ad9fe89
        .condition a{
            display:inline-block;
            padding: 3px 5px;
            border: 1px solid black;
        }
        .condition a.active{
            background-color: brown;
        }
    531ac245ce3e4fe3d50054a55f265927
9c3bca370b5104690d9ef395f2c5f8d1
6c04bd5ca3fcae76e30b72ad730ca86d
    c1a436a314ed609750bd7c7d319db4da过滤条件2e9b454fa8428549ca2e64dfac4625cd


    dc6dce4a544fdca2df29d5ac0ea9906b
        {% if kwargs.article_type == 0 %}
            c1650df1bf28ebb320e3f06f028cceca全部5db79b134e9f6b82c0b36e0489ee08ed
        {% else %}
            c1650df1bf28ebb320e3f06f028cceca全部5db79b134e9f6b82c0b36e0489ee08ed
        {% endif %}

        {% for row in article_type %}
            {% if row.id == kwargs.article_type %}
                8fc2ca070d67d215118cea57248d5115{{ row.caption }}5db79b134e9f6b82c0b36e0489ee08ed
            {% else %}
                f1c526059e6dca0aec95c389326630c2{{ row.caption }}5db79b134e9f6b82c0b36e0489ee08ed
            {% endif %}
        {% endfor %}
    16b28748ea4df4d9c2150843fecfba68

    dc6dce4a544fdca2df29d5ac0ea9906b
        {% if kwargs.category == 0 %}
            df70f7b565cfeab50f6266d13e7aae74全部5db79b134e9f6b82c0b36e0489ee08ed
        {% else %}
            df70f7b565cfeab50f6266d13e7aae74全部5db79b134e9f6b82c0b36e0489ee08ed
        {% endif %}

        {% for row in category %}
            {% if row.id == kwargs.category %}
                c5fdd0f19c8a956b13936b2ed0f418f2{{ row.caption }}5db79b134e9f6b82c0b36e0489ee08ed
            {% else %}
                c5fdd0f19c8a956b13936b2ed0f418f2{{ row.caption }}5db79b134e9f6b82c0b36e0489ee08ed
            {% endif %}
        {% endfor %}
    16b28748ea4df4d9c2150843fecfba68

    c1a436a314ed609750bd7c7d319db4da查询结果2e9b454fa8428549ca2e64dfac4625cd
    ff6d136ddc5fdfeffaf53ff6ee95f185
    {% for row in articles %}
        25edfb22a4f469ecb59f1190150159c6{{ row.id }}-{{ row.title }}------[{{ row.article_type.caption }}]-[{{ row.category.caption }}]bed06894275b65c1ab86501b08a632eb
    {% endfor %}
    929d1f5ca49e04fdcb27f9465b944689
36cc49f0c466276486e50c850b7e4956
73a6ac4ed44ffec12cee46588e518a5e

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類型是部落格定死的數據,後期不會做變動,可以把資料載入到記憶體當中,加快查詢速度

76c82f278ac045591c9159d381de2c57
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
    a80eb7cbb6fff8b0ff70bae37074b813
    b2386ffb911b14667cb8f0f91ea547a7Title6e916e0f7d1e588d4f442bf645aedb2f
    c9ccee2e6ea535a969eb3f532ad9fe89
        .condition a{
            display:inline-block;
            padding: 3px 5px;
            border: 1px solid black;
        }
        .condition a.active{
            background-color: brown;
        }
    531ac245ce3e4fe3d50054a55f265927
9c3bca370b5104690d9ef395f2c5f8d1
6c04bd5ca3fcae76e30b72ad730ca86d
    c1a436a314ed609750bd7c7d319db4da过滤条件2e9b454fa8428549ca2e64dfac4625cd

    dc6dce4a544fdca2df29d5ac0ea9906b
        {% if kwargs.article_type_id == 0 %}
            9d54c0841deaf5461b945d32b7fb4fdc全部5db79b134e9f6b82c0b36e0489ee08ed
        {% else %}
            9d54c0841deaf5461b945d32b7fb4fdc全部5db79b134e9f6b82c0b36e0489ee08ed
        {% endif %}

        {% for row in article_type%}
            {% if row.0 == kwargs.article_type_id %}
                10f3f6439facab4314cfbe4e3175876d{{ row.1 }}5db79b134e9f6b82c0b36e0489ee08ed
            {% else %}
                a20c8a20660a4e1f867202ed670ff3b0{{ row.1 }}5db79b134e9f6b82c0b36e0489ee08ed
            {% endif %}
        {% endfor %}
    16b28748ea4df4d9c2150843fecfba68

    dc6dce4a544fdca2df29d5ac0ea9906b
        {% if kwargs.category_id == 0 %}
            73f255b70dccd9c638775a7513655ec1全部5db79b134e9f6b82c0b36e0489ee08ed
        {% else %}
            73f255b70dccd9c638775a7513655ec1全部5db79b134e9f6b82c0b36e0489ee08ed
        {% endif %}

        {% for row in category %}
            {% if row.id == kwargs.category_id %}
                51842ade3c1731ef36f6a85f509e3264{{ row.caption }}5db79b134e9f6b82c0b36e0489ee08ed
            {% else %}
                51842ade3c1731ef36f6a85f509e3264{{ row.caption }}5db79b134e9f6b82c0b36e0489ee08ed
            {% endif %}
        {% endfor %}
    16b28748ea4df4d9c2150843fecfba68

    c1a436a314ed609750bd7c7d319db4da查询结果2e9b454fa8428549ca2e64dfac4625cd
    ff6d136ddc5fdfeffaf53ff6ee95f185
    {% for row in articles %}
        25edfb22a4f469ecb59f1190150159c6{{ row.id }}-{{ row.title }}------[{{ row.article_type }}]-[{{ row.category.caption }}]bed06894275b65c1ab86501b08a632eb
    {% endfor %}
    929d1f5ca49e04fdcb27f9465b944689
36cc49f0c466276486e50c850b7e4956
73a6ac4ed44ffec12cee46588e518a5e

article.html
from 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)

数据库文件.py
from 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 %}
76c82f278ac045591c9159d381de2c57
100db36a723c770d327fc0aef2ce13b1
93f0f5c25f18dab9d176bd4f6de5d30e
    a80eb7cbb6fff8b0ff70bae37074b813
    b2386ffb911b14667cb8f0f91ea547a7Title6e916e0f7d1e588d4f442bf645aedb2f
    c9ccee2e6ea535a969eb3f532ad9fe89
        .condition a{
            display:inline-block;
            padding: 3px 5px;
            border: 1px solid black;
        }
        .condition a.active{
            background-color: brown;
        }
    531ac245ce3e4fe3d50054a55f265927
9c3bca370b5104690d9ef395f2c5f8d1
6c04bd5ca3fcae76e30b72ad730ca86d
    c1a436a314ed609750bd7c7d319db4da过滤条件2e9b454fa8428549ca2e64dfac4625cd
    dc6dce4a544fdca2df29d5ac0ea9906b
        {% filter_all  kwargs 'article_type'%}

        {% filter_single article_type kwargs 'article_type'%}
    16b28748ea4df4d9c2150843fecfba68
    dc6dce4a544fdca2df29d5ac0ea9906b
        {% filter_all  kwargs 'category'%}
        {% filter_single category kwargs 'category'%}
    16b28748ea4df4d9c2150843fecfba68

    c1a436a314ed609750bd7c7d319db4da查询结果2e9b454fa8428549ca2e64dfac4625cd
    ff6d136ddc5fdfeffaf53ff6ee95f185
    {% for row in articles %}
        25edfb22a4f469ecb59f1190150159c6{{ row.id }}-{{ row.title }}------[{{ row.article_type.caption }}]-[{{ row.category.caption }}]bed06894275b65c1ab86501b08a632eb
    {% endfor %}
    929d1f5ca49e04fdcb27f9465b944689
36cc49f0c466276486e50c850b7e4956
73a6ac4ed44ffec12cee46588e518a5e

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 = 'd0bc4868ae1f1ff1c94f379d51d89899 全部 5db79b134e9f6b82c0b36e0489ee08ed'%(kwargs['category'])
        else:
            tmp = '5b4a38184beb11dcff07b41757a60e18 全部 5db79b134e9f6b82c0b36e0489ee08ed'%(kwargs['category'])
 
    elif type_str == 'category':
        if kwargs['category'] == 0:
            tmp = '53ffd3320390aae5c9a1b7577e83bd73 全部 5db79b134e9f6b82c0b36e0489ee08ed' % (kwargs['article_type'])
        else:
            tmp = 'ea4c005b7a5cd7a87c1b4bb223203114 全部 5db79b134e9f6b82c0b36e0489ee08ed' % (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 = '9dba6e1a712676182e9928b187d05ff4%s5db79b134e9f6b82c0b36e0489ee08ed\n'%(row.id,kwargs['category'],row.caption)
            else:
                tag = 'd6329b2a69cc11866deec56d01dda4a9%s5db79b134e9f6b82c0b36e0489ee08ed\n' % (row.id, kwargs['category'],row.caption)
            tmp +=tag
    elif type_str == 'category':
        for row in type_obj:
            if row.id == kwargs['category']:
                tag = '9dba6e1a712676182e9928b187d05ff4%s5db79b134e9f6b82c0b36e0489ee08ed\n' % (kwargs['article_type'],row.id, row.caption)
            else:
                tag = 'd6329b2a69cc11866deec56d01dda4a9%s5db79b134e9f6b82c0b36e0489ee08ed\n' % (kwargs['article_type'], row.id, row.caption)
            tmp += tag
 
    return mark_safe(tmp)

HTML檔案主體內容:

{% load filter %}
6c04bd5ca3fcae76e30b72ad730ca86d
    c1a436a314ed609750bd7c7d319db4da过滤条件2e9b454fa8428549ca2e64dfac4625cd
    4981d39361bc2844bf84fbb6c43c223d
        {% filter_all  kwargs 'article_type'%}
 
        {% filter_single article_type kwargs 'article_type'%}
    16b28748ea4df4d9c2150843fecfba68
    4981d39361bc2844bf84fbb6c43c223d
        {% filter_all  kwargs 'category'%}
        {% filter_single category kwargs 'category'%}
    16b28748ea4df4d9c2150843fecfba68
 
    c1a436a314ed609750bd7c7d319db4da查询结果2e9b454fa8428549ca2e64dfac4625cd
    ff6d136ddc5fdfeffaf53ff6ee95f185
    {% for row in articles %}
        25edfb22a4f469ecb59f1190150159c6{{ row.id }}-{{ row.title }}------[{{ row.article_type.caption }}]-[{{ row.category.caption }}]bed06894275b65c1ab86501b08a632eb
    {% endfor %}
    929d1f5ca49e04fdcb27f9465b944689
36cc49f0c466276486e50c850b7e4956

JSONP

  JSONP(JSON with Padding)是JSON的一種「使用模式”,可用於解決主流瀏覽器的跨域資料存取的問題。由於同源策略,一般來說位於 server1.example.com 的網頁無法與不是 server1.example.com的伺服器溝通,而 HTML 的3f1c4e4b6b16bbbd69b2ee476dc4f83a 元素是例外。利用 3f1c4e4b6b16bbbd69b2ee476dc4f83a 元素的這個開放策略,網頁可以得到從其他來源動態產生的 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?cityId=101121301')
    response.encoding = 'utf-8'     # 进行编码
 
    return render(request,'jsonp.html',{'result':response.text})  # response.text 请求内容

HTML檔案:

<body>
    <h1>后台获取的结果</h1>
    {{ result }}
    <h1>js直接获取结果</h1>
    <input type="button" value="获取数据" onclick="getContent();" />
    <div id="container"></div>
    <script src="/static/jquery-1.8.2.js"></script>
    <script>
        function getContent() {
            var xhr = new XMLHttpRequest();         // 创建对象
            xhr.open(&#39;GET&#39;, &#39;http://weatherapi.market.xiaomi.com/wtr-v2/weather?cityId=101121301&#39;); // GET方式打开
            xhr.onreadystatechange = function () {  // 收到返回值时执行
                console.log(xhr.responseText);
            };
            xhr.send()  // 发送
        }
    </script>
</body>

#註:點擊js直接取得結果時,瀏覽器顯示下面報錯訊息,由於瀏覽器只接受http:/ /127.0.0.1:8000發過來的信息,對於天氣網站發過來的信息直接屏蔽掉了,這就是同源策略,那有沒有什麼方式可以解決?

XMLHttpRequest cannot load http://weatherapi.market.xiaomi.com/wtr-v2/weather?cityId=101121301. No &#39;Access-Control-Allow-Origin&#39; header is present on the requested resource. Origin &#39;http://127.0.0.1:8000&#39; is therefore not allowed access.

2、巧用script標籤src屬性

script標籤不受同源策略的影響

處理檔:

import requests
def jsonp(request):
    # 获取url信息
    response = requests.get(&#39;http://weatherapi.market.xiaomi.com/wtr-v2/weather?cityId=101121301&#39;)
    response.encoding = &#39;utf-8&#39;     # 进行编码
 
    return render(request,&#39;jsonp.html&#39;,{&#39;result&#39;:response.text})  # response.text 请求内容
 
def jsonp_api(request):
    return HttpResponse('alert(123)')

HTML檔:

<body>
    <h1>后台获取的结果</h1>
    {{ result }}
    <h1>js直接获取结果</h1>
    <input type="button" value="获取数据" onclick="getContent();" />
    <div id="container"></div>
    <script>
        function getContent() {
            var tag = document.createElement(&#39;script&#39;);
            tag.src = &#39;/jsonp_api.html&#39;;
            document.head.appendChild(tag);
         //   document.head.removeChild(tag);
        }
    </script>
</body>

註:js請求時為了方便,還是請求的是當前程式url;執行完上面程式碼會發現一個神奇的狀況,頁面會彈出123信息,表明script獲取信息成功

 

3、對前後端稍加改造,使用方法更加動態化

處理文件:

def jsonp(request):
 
    return render(request,&#39;jsonp.html&#39;)  # response.text 请求内容
 
def jsonp_api(request):
    func = request.GET.get(&#39;callback&#39;)  # 获取用户callback参数
    content = &#39;%s(10000)&#39;%func          # 执行func(10000)函数
 
    return HttpResponse(content)

HTML檔: 

<body>
    <h1>后台获取的结果</h1>
    {{ result }}
    <h1>js直接获取结果</h1>
    <input type="button" value="获取数据" onclick="getContent();" />
    <div id="container"></div>
    <script>
        function getContent() {
            var tag = document.createElement(&#39;script&#39;);
            tag.src = &#39;/jsonp_api.html?callback=list&#39;;  // 自定义callback参数,与后台达成默契
            document.head.appendChild(tag);
         //   document.head.removeChild(tag);
        }
        function list(arg){         // 自定义函数与callback=list相对应
               alert(arg);
            }
    </script>
</body>

註:js發送請求時,帶上callback參數,然後定義參數對應的方法,後台會把資料傳入此方法內並且執行執行;至於要列印還是彈框,就看使用者自己的需求去處理了;jsonp的原理和實作過程就是上述程式碼的實作

 

4、實例應用+ajax

##處理文件:

import requests
def jsonp(request):
    response = requests.get(&#39;http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=1454376870403&#39;)
    response.encoding = &#39;utf-8&#39;  # 进行编码
 
    return render(request, &#39;jsonp.html&#39;, {&#39;result&#39;: response.text})  # response.text 请求内容

HTML檔:

<body>
    <h1>后台获取的结果</h1>
    {{ result }}
    <h1>js直接获取结果</h1>
    <input type="button" value="获取数据" onclick="getContent();" />
    <div id="container"></div>
    <script src="/static/jquery-1.8.2.js"></script>
    <script>
        function getContent() {
            $.ajax({
                url: &#39;http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=1454376870403&#39;,
                type: &#39;POST&#39;,
                dataType: &#39;jsonp&#39;,     // 即使写的type是POST也是按照GET请求发送
                jsonp: &#39;callback&#39;,
                jsonpCallback: &#39;list&#39;
            });
        }
 
        function list(arg){         // 自定义函数与callback=list相对应
            console.log(arg);
            var data = arg[&#39;data&#39;];
            for(k in data){
                var tr = document.createElement(&#39;td&#39;);
                var week = data[k][&#39;week&#39;];
                var list = data[k][&#39;list&#39;];
                tr.textContent =week
                document.body.appendChild(tr);
                console.log(week);
                for(i in list){
                    var name = list[i][&#39;name&#39;];
                    console.log(name)
        }}}
    </script>
</body>
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中文網!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn