encoding utf-8 from django http import HttpResponse from django shortc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- encoding: utf-8 -*_
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.views.decorators.http import require_http_methods
from django.core import serializers
from django.utils import simplejson
from BeautifulSoup import BeautifulSoup, Comment
from lxml.html.clean import Cleaner
import lxml.html
from RemoteTypograf import RemoteTypograf
from lxml.html import fromstring
import re
@require_http_methods(["GET"])
def pars(request):
cleaner = Cleaner(style=True, links=True, add_nofollow=True, page_structure=True, safe_attrs_only=True)
bordertbl = request.GET['border']
cellpaddingtbl = request.GET['cellpadding']
cellspacingtbl = request.GET['cellspacing']
classtbl = request.GET['class']
widthtbl = request.GET['width']
text_tbl = request.GET['message']
text_tbl = cleaner.clean_html(text_tbl)
data = re.sub('class="[a-zA-Z0-9]*"|align="[a-zA-Z0-9]*"|valign="[a-zA-Z0-9]*"| bgcolor="[\#a-zA-Z0-9]*"| width="[\#\%a-zA-Z0-9]*"| id="[\#\%a-zA-Z0-9]*"', "", text_tbl)
return HttpResponse(data)