f = urlopen(d2securl)
i = info.find_one({"db": "d2sec"})
if i is not None:
if f.headers["last-modified"] == i["last-modified"]:
sys.exit("Not modified")
// parse xml and store in database
parser.parse(f)
bulk = d2sec.initialize_ordered_bulk_op()
for exploit in progressbar(ch.d2sec):
print (exploit)
if args.v:
print (exploit)
bulk.find({"id": exploit["id"]}).upsert().update({"$set": {"id": exploit["id"], "url": exploit["url"], "name": exploit["name"]}})
bulk.execute()
//update database info after successful program-run
info.update({"db": "d2sec"}, {"$set": {"last-modified": f.headers["last-modified"]}}, upsert=True)
After Change
// check modification date
f = urlopen(d2securl)
i = info.find_one({"db": "d2sec"})
last_modified = parse_datetime(f.headers["last-modified"])
if i is not None:
if last_modified == i["last-modified"]:
sys.exit("Not modified")
// parse xml and store in database
parser.parse(f)
bulk = d2sec.initialize_ordered_bulk_op()
for exploit in progressbar(ch.d2sec):
print (exploit)
if args.v:
print (exploit)
bulk.find({"id": exploit["id"]}).upsert().update({"$set": {"id": exploit["id"], "url": exploit["url"], "name": exploit["name"]}})
bulk.execute()
//update database info after successful program-run
info.update({"db": "d2sec"}, {"$set": {"last-modified": last_modified}}, upsert=True)