How to use the gne.defaults.PUBLISH_TIME_META function in gne

To help you get started, we’ve selected a few gne examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kingname / GeneralNewsExtractor / gne / extractor / TimeExtractor.py View on Github external
def extract_from_meta(self, element: HtmlElement) -> str:
        """
        一些很规范的新闻网站,会把新闻的发布时间放在 META 中,因此应该优先检查 META 数据
        :param element: 网页源代码对应的Dom 树
        :return: str
        """
        for xpath in PUBLISH_TIME_META:
            publish_time = element.xpath(xpath)
            if publish_time:
                return ''.join(publish_time)
        return ''