Exemple #1
0
def addToWarc(w, uri, mime, date, ip):
    ##  don't forget to check return values of each functions  ##
    r = WRecord()

    # change the record type if you want
    r.setRecordType(warc.WARC_RESOURCE_RECORD)
    r.setTargetUri(uri, len(uri))
    r.setDate(date, len(date))
    r.setContentType(mime, len(mime))
    # use your "unique identifier" function here
    s = time.strftime("%a, %Y-%m-%dT%H:%M:%SZ", time.localtime())
    sh = sha.new(uri + s)
    rid = sh.hexdigest()
    rid = "uuid:" + rid
    r.setRecordId(rid, len(rid))
    r.setIpAddress(ip, len(ip))
    r.setContentFromFileName(tmpfile)

    w.storeRecord(r)
    r.destroy()
Exemple #2
0
def addToWarc(w, uri, mime, date, ip):
    ##  don't forget to check return values of each functions  ##
    r = WRecord()

    # change the record type if you want
    r.setRecordType(warc.WARC_RESOURCE_RECORD)
    r.setTargetUri(uri, len(uri))
    r.setDate(date, len(date))
    r.setContentType(mime, len(mime))
    # use your "unique identifier" function here
    s = time.strftime("%a, %Y-%m-%dT%H:%M:%SZ", time.localtime())
    sh = sha.new(uri + s)
    rid = sh.hexdigest()
    rid = "uuid:" + rid
    r.setRecordId(rid, len(rid))
    r.setIpAddress(ip, len(ip))
    r.setContentFromFileName(tmpfile)

    w.storeRecord(r)
    r.destroy()