你有数据就不需要爬虫。
爬虫就是用来爬数据的。
安装MYSQLdb包:Ubuntu $ sudo apt-get install mysql-server ;
$ sudo apt-get install python-mysqldb
#encoding=utf-8
import re
import urllib2
import MySQLdb
from BeautifulSoup import BeautifulSoup
aaa=3640
url1="http://bbs.ustc.edu.cn/cgi/bbstdoc?board=PieBridge&start="
while aaa>0:
aaa=aaa-20
aaa1=str(aaa)
url11=url1+aaa1
fp=urllib2.urlopen(url11)
try:
s=fp.read().decode("gb2312",'ignpore')
s=re.sub("charset=gb2312","charset=utf-8",s,re.I)
s=s.encode('utf-8','ignore')
except:
s=fp.read()
soup=BeautifulSoup(s)
polist=soup.findAll('span')
print polist[0].contents[0]