SVN: security/getCVEdesc.py

shadzik shadzik at pld-linux.org
Tue Aug 4 12:44:58 CEST 2009


Author: shadzik
Date: Tue Aug  4 12:44:58 2009
New Revision: 10448

Modified:
   security/getCVEdesc.py
Log:
- another way using pyquery (but sucks in a matter of counting lines, this would be done easier if a proper class was set to the description tag)


Modified: security/getCVEdesc.py
==============================================================================
--- security/getCVEdesc.py	(original)
+++ security/getCVEdesc.py	Tue Aug  4 12:44:58 2009
@@ -1,13 +1,10 @@
 #!/usr/bin/python
 
-import os
 import sys
-import re
-import readline
+from pyquery import PyQuery as pq
 import urllib2
 
 
-lines = []
 
 def parseHtml():
 	try:
@@ -15,25 +12,12 @@
 	except(IndexError):
 		print "Usage: %s cveId" % sys.argv[0]
 		return
-	html = urllib2.urlopen("http://cve.mitre.org/cgi-bin/cvename.cgi?name=%s" % cveID)
-	#f = open(html, 'r')
-	f = html.read()
-	read = f.split("\n")
-	for l in read:
-		l = l.strip()
-		lines.append(l)
-	for i in range(len(lines)):
-		if re.findall("Description", lines[i]):
-			log = 3
-			while (lines[i+log] != "</td>"):
-				print lines[i+log].replace('<td colspan="2">','')
-				log = log + 1
-def getQueue():
-	try:
-		cveID = sys.argv[1]
-	except(IndexError):
-		return
-	os.popen("wget --quiet -N -O cve.html http://cve.mitre.org/cgi-bin/cvename.cgi?name=%s" % cveID)
+	html = urllib2.urlopen("http://cve.mitre.org/cgi-bin/cvename.cgi?name=%s" % cveID).read()
+	html = pq(html)
+	line = 0
+	for i in html("td"):
+		if line == 55:
+			print i.text
+		line = line + 1
 
-#getQueue()
 parseHtml()


More information about the pld-cvs-commit mailing list