RE匹配pdfURL地址[Python基础]

python

python">import re

str = """

<script language="javascript" type="f9d183f87da800c789dfdf6d-text/javascript">location.href="https://www.agialpress.com/articles/cellular-mechanisms

-of-oestrogen-in-breast-cancer-development.pdf";</script><script src="https://ajax.cloudflare.com/cdn-cgi/scripts/7089c43e/cloudflare-static/rocket-loader.min.js"

data-cf-settings="f9d183f87da800c789dfdf6d-|49" defer=""></script>

"""

regular = re.findall("(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*,]|(?:%[0-9a-fA-F][0-9a-fA-F]))+pdf)|([a-zA-Z]+.w+.+[a-zA-Z0-9/_]+pdf)",str)

如果是匹配url地址则用

regular = re.findall(r"(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*,]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)|([a-zA-Z]+.w+.+[a-zA-Z0-9/_]+$)",str)

以上是 RE匹配pdfURL地址[Python基础] 的全部内容, 来源链接: utcz.com/z/530570.html

回到顶部