usr bin python coding utf-8 import re sys os getopt cStringIO MySQLdb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re,sys,os,getopt,cStringIO,MySQLdb,traceback,datetime,time,random,urlparse,urllib
from chardet.universaldetector import UniversalDetector
from pycurl import *
from lxml.html import fromstring,tostring
dbconn = MySQLdb.connect(db='1', host='localhost', port=3306, user='1', passwd='111')
dbconn.set_character_set('utf8')
dbconn.autocommit(True)
cursor = dbconn.cursor()
cursor.execute("set names 'utf8'")
[MEGA CROP]
***
title,keywords,descriptions,self.variable['ID'] = .decode('...').encode('utf-8')
***
cursor.execute("""update test set title=%s, keywords=%s, description=%s, iswork='1' where id=%s""", (title,keywords,descriptions,self.variable['ID']))