sks.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:meg-server 作者: Argonne-National-Laboratory 项目源码 文件源码
def search_key(cfg, search_str):
    """
    Search for a key by a given string
    """
    content, status_code = make_sks_request(
        cfg, requests.get, "lookup", {"op": "index", "search": search_str}, None
    )
    if status_code != 200:
        return content, status_code
    bs = BeautifulSoup(content, HTML_PARSER)
    regex = re.compile(r"^pub *\d{3,4}\w\/([\w\d]{8})")
    ids = []
    for pre in bs.findAll("pre"):
        match = regex.search(pre.text.strip("\r\n"))
        if match and not "KEY REVOKED" in pre.text:
            ids.append(match.groups()[0])
    return {"ids": ids}, status_code
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号