-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallboards.py
38 lines (32 loc) · 1019 Bytes
/
allboards.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
from spidder import board
from base import boards
import datetime
import time
import pymysql
conn=pymysql.connect(host='127.0.0.1',port=3306,user='root',passwd='123456',db='lilybbs',charset='utf8')
cur=conn.cursor()
date=datetime.datetime.now()
date=date-datetime.timedelta(days=1)
def judge(item):
post_time=item[2]
if post_time<date:
return False
return True
def conduct(item):
# print(item)
sql='insert into posts_base_info(boardId,sequence,sender,post_time,title,url,reply,popularity) values(%s,%s,%s,%s,%s,%s,%s,%s)'
s=(b[4],item[0],str(item[1]),item[2],item[3],item[4],item[5],item[6])
cur.execute(sql,s)
try:
for b in boards:
# print(b[0])
board(b[0],judge,conduct)
time.sleep(0.5)
## b=['Basketball','篮球','体育','cobratoxin',29]
## board(b[0],judge,conduct)
conn.commit()
finally:
cur.close()
conn.close()
##board('FleaMarket','boards/FleaMarket.txt',
## datetime.datetime.strptime('2016-5-7','%Y-%m-%d'))