forked from fubendong/wangw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclear.py
78 lines (58 loc) · 1.65 KB
/
clear.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
some db interface
"""
import pymongo
import pycurl
from BeautifulSoup import BeautifulSoup
import StringIO
import time
from django.utils.encoding import smart_str, smart_unicode
import os
import traceback
from datetime import datetime,timedelta
import json
#from smallgfw import GFW
import os
import os.path
from pymongo import ASCENDING,DESCENDING
import requests
from urlparse import urlparse
import sys
import urlparse
import re
import types
import sys
import logging
import urllib
from urllib import urlencode
import time, MySQLdb
logging.basicConfig(filename = os.path.join(os.getcwd(), 'log.txt'),level = logging.WARN, filemode = 'w', format = '%(asctime)s - %(levelname)s: %(message)s')
mktime=lambda dt:time.mktime(dt.utctimetuple())
conn=MySQLdb.connect(host="localhost",user="root",passwd="fubendong",db="wangwang",charset="utf8")
cursor = conn.cursor()
def clears ():
filename = "old"
file = open(filename)
type = "phone";
i = 1
try:
while 1:
try:
line = file.readline()
if not line:
break
print line
username = line.strip('\n')
# username = result[0].encode('UTF8')
sql = "update wangwang_tmall set type = 0 where username = '%s' " % username
print sql
res = cursor.execute(sql)
print res
except Exception ,e:
print e
except Exception ,e:
print e
if __name__ == "__main__":
clears()