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


Python Page.add_page方法代码示例

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


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

示例1: post

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import add_page [as 别名]
    def post(self):
        post_data = loads(self.request.body)
        url = post_data["url"]
        score = float(post_data.get("score", self.application.config.DEFAULT_PAGE_SCORE))

        result = yield Page.add_page(
            self.db,
            self.application.cache,
            url,
            score,
            self.application.http_client.fetch,
            self.application.event_bus.publish,
            self.application.config,
        )

        created, url, result = result

        if not created and result["reason"] == "invalid_url":
            self.set_status(400, "Invalid url [%s]" % url)
            self.write_json(
                {"reason": "invalid_url", "url": url, "status": result["status"], "details": result["details"]}
            )
            return

        if not created and result["reason"] == "redirect":
            self.set_status(400, "Redirect URL [%s]" % url)
            self.write_json({"reason": "redirect", "url": url, "effectiveUrl": result["effectiveUrl"]})
            return

        self.write(str(result))
        self.finish()
开发者ID:ricardodani,项目名称:holmes-api,代码行数:33,代码来源:page.py

示例2: enqueue

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import add_page [as 别名]
    def enqueue(self, urls):
        if not urls:
            return

        for url, score in urls:
            Page.add_page(
                self.db,
                self.cache,
                url,
                score,
                self.async_get_func,
                self.publish,
                self.config,
                self.handle_page_added
            )

        self.wait_for_async_requests()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:19,代码来源:reviewer.py

示例3: post

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import add_page [as 别名]
    def post(self):
        post_data = loads(self.request.body)
        url = post_data['url']
        score = float(post_data.get('score', self.application.config.DEFAULT_PAGE_SCORE))

        result = yield Page.add_page(
            self.db,
            self.application.cache,
            url,
            score,
            self.application.http_client.fetch,
            self.application.event_bus.publish,
            self.application.config
        )

        created, url, result = result

        if not created and result['reason'] == 'invalid_url':
            self.set_status(400, 'Invalid url [%s]' % url)
            self.write_json({
                'reason': 'invalid_url',
                'url': url,
                'status': result['status'],
                'details': result['details']
            })
            return

        if not created and result['reason'] == 'redirect':
            self.set_status(400, 'Redirect URL [%s]' % url)
            self.write_json({
                'reason': 'redirect',
                'url': url,
                'effectiveUrl': result['effectiveUrl']
            })
            return

        self.write(str(result))
        self.finish()
开发者ID:pombredanne,项目名称:holmes-api,代码行数:40,代码来源:page.py

示例4: post

# 需要导入模块: from holmes.models import Page [as 别名]
# 或者: from holmes.models.Page import add_page [as 别名]
    def post(self):
        post_data = loads(self.request.body)
        url = post_data["url"]
        score = float(post_data.get("score", self.application.config.DEFAULT_PAGE_SCORE))

        result = yield Page.add_page(
            self.db,
            self.application.cache,
            url,
            score,
            self.application.http_client.fetch,
            self.application.event_bus.publish,
            self.application.config,
            self.application.girl,
            self.application.default_violations_values,
            self.application.violation_definitions,
        )

        created, url, result = result

        if not created and result["reason"] == "invalid_url":
            self.set_status(400, self._("Invalid url [%s]") % url)
            self.write_json(
                {"reason": "invalid_url", "url": url, "status": result["status"], "details": result["details"]}
            )
            return

        if not created and result["reason"] == "redirect":
            self.set_status(400, self._("Supplied URL is a redirect [%s]") % url)
            self.write_json({"reason": "redirect", "url": url, "effectiveUrl": result["effectiveUrl"]})
            return

        yield self.application.cache.add_next_job_bucket(result, url)

        self.write(str(result))
        self.finish()
开发者ID:skyonamine,项目名称:holmes-api,代码行数:38,代码来源:page.py


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