示例#1
0
def extract_article():
    """GET data url required"""
    response.content_type = 'application/json'
    url = request.query.getone("url")
    if not url:
        abort(404)

    metadoc = Metadoc(url=url)
    metadoc._prepare()
    metadoc._query_domain()
    metadoc._query_extract()

    payload = metadoc._render()  # Preserve order
    return json.dumps(payload)
示例#2
0
def extract_article():
    """POST data url required, html optional"""
    response.content_type = 'application/json'
    url = request.forms.get("url")

    if not url:
        abort(404)

    metadoc = Metadoc(url=url)
    metadoc._query_domain()
    metadoc._query_extract()

    payload = metadoc._render()  # Preserve order
    return json.dumps(payload)