searx/engines/duden.py
def response(resp):
    '''post-response callback
    resp: requests response object
    '''
    results = []

    dom = html.fromstring(resp.text)

    try:
        number_of_results_string = re.sub('[^0-9]', '', dom.xpath(
            '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()')[0]
        )

        results.append({'number_of_results': int(number_of_results_string)})

    except:
        logger.debug("Couldn't read number of results.")
        pass

    for result in dom.xpath('//section[@class="wide" and not(contains(@style,"overflow:hidden"))]'):
        try:
            logger.debug("running for %s" % str(result))
            link = result.xpath('.//h2/a')[0]
            url = link.attrib.get('href')
            title = result.xpath('string(.//h2/a)')
            content = extract_text(result.xpath('.//p'))
            # append result
            results.append({'url': url,
                            'title': title,
                            'content': content})
        except:
            logger.debug('result parse error in:\n%s', etree.tostring(result, pretty_print=True))
            continue

    return results
def response(resp):
    '''post-response callback
    resp: requests response object
    '''
    results = []

    dom = html.fromstring(resp.text)

    try:
        number_of_results_string = re.sub('[^0-9]', '', dom.xpath(
            '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()')[0]
        )

        results.append({'number_of_results': int(number_of_results_string)})

    except:
        logger.debug("Couldn't read number of results.")
        pass

    for result in dom.xpath('//section[@class="wide" and not(contains(@style,"overflow:hidden"))]'):
        try:
            logger.debug("running for %s" % str(result))
            link = result.xpath('.//h2/a')[0]
            url = link.attrib.get('href')
            title = result.xpath('string(.//h2/a)')
            content = extract_text(result.xpath('.//p'))
            # append result
            results.append({'url': url,
                            'title': title,
                            'content': content})
        except:
            logger.debug('result parse error in:\n%s', etree.tostring(result, pretty_print=True))
            continue

    return results
def response ( resp ) : results = [ ] dom = html . fromstring ( resp . text ) try : number_of_results_string = re . sub ( '[^0-9]' , '' , dom . xpath ( '//a[@class="active" and contains(@href,"/suchen/dudenonline")]/span/text()' ) [ 0 ] ) results . append ( { 'number_of_results' : int ( number_of_results_string ) } ) except : logger . debug ( "Couldn't read number of results." ) pass for result in dom . xpath ( '//section[@class="wide" and not(contains(@style,"overflow:hidden"))]' ) : try : logger . debug ( "running for %s" % str ( result ) ) link = result . xpath ( './/h2/a' ) [ 0 ] url = link . attrib . get ( 'href' ) title = result . xpath ( 'string(.//h2/a)' ) content = extract_text ( result . xpath ( './/p' ) ) # append result results . append ( { 'url' : url , 'title' : title , 'content' : content } ) except : logger . debug ( 'result parse error in:\n%s' , etree . tostring ( result , pretty_print = True ) ) continue return results
post-response callback
    resp: requests response object
post - response callback resp : requests response object