コード例 #1
0
ファイル: nyt.py プロジェクト: Bookaa/compass
def parseTimesResultRecursive(element, out, date):
    if "geo_facet_item" in element.tag:
        if element.text is not None:
            k = False
            parent = element.getparent().getparent()
            for c in parent:
                if "updated_date" in c.tag:
                    publishdate = time.mktime(time.strptime(c.text[:-6],
                        "%Y-%m-%dT%H:%M:%S"))
                    publishdate = publishdate + int(c.text[-5:-3])*60*60
                    if publishdate > date:
                        k = True
                    lastupdate.append(publishdate)
            if k:
                out.add(('nyt',
                    geoloc.getCoordinates(element.text.encode('utf-8'))))
    else:
        for child in element:
            parseTimesResultRecursive(child, out, date)
コード例 #2
0
ファイル: twitter.py プロジェクト: Bookaa/compass
def parseTwitterResultRecursive(element, out, depth, date):
    if "location" in element.tag:
        if element.text is not None:
            k = False
            parent = element.getparent()
            for c in parent:
                if "published" in c.tag:
                    publishdate = time.mktime(time.strptime(c.text,
                        "%Y-%m-%dT%H:%M:%SZ"))
                    if publishdate > date:
                        k = True
                    lastupdate.append(publishdate)
            if k:
                x = geoloc.getCoordinates(element.text.encode('utf-8'))
                if x is not None:
                    out.add(('twitter', x))
    else:
        if depth < 2:
            for child in element:
                parseTwitterResultRecursive(child, out, depth + 1, date)