import urllib2 from BeautifulSoup import BeautifulStoneSoup import MyS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import urllib2
from BeautifulSoup import BeautifulStoneSoup
import MySQLdb
db = MySQLdb.connect("localhost", "xml", "xml", "xml")
cursor = db.cursor()
xml = urllib2.urlopen("http://nvd.nist.gov/download/nvdcve-2008trans.xml")
soup = BeautifulStoneSoup(xml)
entries = soup.findAll('entry')
for i in entries:
cursor.execute("""INSERT INTO test SET
test1 = %s, test2 = %s, test3 = %s""", (i.desc.descript['language'], i.desc.descript['modified'], i.desc.descript['translator']))