当前位置: 首页>>代码示例>>Python>>正文


Python Search.run方法代码示例

本文整理汇总了Python中search.Search.run方法的典型用法代码示例。如果您正苦于以下问题:Python Search.run方法的具体用法?Python Search.run怎么用?Python Search.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在search.Search的用法示例。


在下文中一共展示了Search.run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: api_organisations

# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import run [as 别名]
def api_organisations():
    timer = Timer()
    timer.start()

    app.logger.debug(request.args)

    filter = {}
    filter["handelsnaam"] = check_args("handelsnaam")
    filter["kvknummer"] = check_args("kvknummer")
    filter["straat"] = check_args("straat")
    filter["huisnummer"] = check_args("huisnummer")
    filter["postcode"] = check_args("postcode")
    filter["plaats"] = check_args("plaats")
    filter["hoofdvestiging"] = check_args_boolean("hoofdvestiging", True, False)
    filter["nevenvestiging"] = check_args_boolean("nevenvestiging", True, False) 
    filter["rechtspersoon"] = check_args_boolean("rechtspersoon", True, False)
    filter["vervallen"] = check_args_boolean("vervallen", False, True)
    filter["uitgeschreven"] = check_args_boolean("uitgeschreven", False, True)

    app.logger.debug(filter)
                                
    if filter["handelsnaam"] == "" and filter["kvknummer"] == "" and filter["straat"] == "" and filter["huisnummer"] == "" and filter["postcode"] == "" and filter["plaats"] == "":
        return unprocessable_entity()
    else:
        if 'startpage' in request.args:
            startpage = int(request.args['startpage'])
        else:
            startpage = 1
        if 'maxpages' in request.args:
            maxpages = int(request.args['maxpages'])
        else:
            maxpages = 1

        try:
            search = Search(filter, startpage, maxpages)
        except NoResultsError:
            return not_found()
        else:
            results = search.run()
            
            timer.stop();
            
            results["total_exectime"] = timer.exectime()
            results["api_version"] = "v1"
            results["release"] = release

            resp = jsonify(results)
            resp.status_code = 200
                                             
            return resp
开发者ID:nidkil,项目名称:python-kvk-web-scraper,代码行数:52,代码来源:service.py

示例2: main

# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import run [as 别名]
def main(args):
    timer = Timer()
    timer.start()
            
    filter = {}
    filter["handelsnaam"] = args.handelsnaam
    filter["kvknummer"] = args.kvknummer
    filter["straat"] = args.straat
    filter["huisnummer"] = args.huisnummer
    filter["postcode"] = args.postcode
    filter["plaats"] = args.plaats
    filter["hoofdvestiging"] = "true" if args.hoofdvestiging == True else "false"
    filter["nevenvestiging"] = "true" if args.nevenvestiging == True else "false"
    filter["rechtspersoon"] = "true" if args.rechtspersoon == True else "false"
    filter["vervallen"] = "1" if args.vervallen == True else "0"
    filter["uitgeschreven"] = "1" if args.uitgeschreven == True else "0"

    logger.debug(filter)

    try:
        search = Search(filter, args.startpage, args.maxpages)
        results = search.run()
    except NoResultsError:
        print "Error: no results found"
        sys.exit(1)

    organisations = results["organisaties"]
    
    if organisations is not None:
        for organisation in organisations:
            print organisation["handelsnaam"] + " [" + organisation["kvk_nummer"]+ "]"
   
    print "" 
    stats = results["stats"]
    print "Gevonden: resultaten=%s, pagina's=%s" % (stats["matches"]["total"], stats["matches"]["pages"])
    print "Ingelezen pagina: van=%s, tot=%s" % (stats["read"]["page_from"], stats["read"]["page_to"])
    
    timer.stop()
        
    print "Exectime: totaal=%s ms, verwerken=%s ms" % (timer.exectime(), stats["exectime"])
开发者ID:nidkil,项目名称:python-kvk-web-scraper,代码行数:42,代码来源:kvkwebscraper.py


注:本文中的search.Search.run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。