BeautifulSoup soup.split() TypeError: 'NoneType' object is not callable

各位大佬,我现在尝试对返回的结果切片,但是一直返回如题的报错,何解?

response = requests.get(head_url, headers=headers)
print(response)
soup = Bs4(response.content, "html.parser")
print(soup)
soup1 = soup.split('url')
print(soup1)

以下是打印出的soup内容


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta content="NO-CACHE" http-equiv="PRAGMA"/>
<script>
function redirectOnLoad() {
var escapedHash = '';
var url = '/saml/authn-request.jsp?saml_request_id=_2CAAAAW6NkFa5ME8wMEkwMDAwMDA4T0k1AAAA3uVxW4A-puDiWV7jZg4vzIJ8Kruhb9ezWoJrOJYXNUsMN8S5EhLoi_ruRrvfO5oXTbVtclAH9Oy5BfY6VFY9aF0SmypuZsR0UzxMQUsmdJnM4IHrsrhunYEgpkXPPkir6L8EfEYWsKVxnykLFK-I9w5R0mc8n5yaIPcPcW4g-jTMdzhh1lukUvHn88CqNeWC7fkDAiYj9pApLmZhXQE71rP-DVuQ4tBNJtSHe3WiuLAac3BqZbQALbZz7pHKoEWLmg&saml_acs=https%3A%2F%2Fenglish1.my.salesforce.com%3Fso%3D00D28000000bkxy&saml_binding_type=HttpRedirect&Issuer=https%3A%2F%2Fenglish1.my.salesforce.com&samlSsoConfig=0LE28000000Gr3E&RelayState=%2Fp%2Fown%2FOrgSharingDetail%3Fst%3D01I28000001nyrv%26setupid%3DSecuritySharing';
if (window.location.hash) {
   escapedHash = '%23' + window.location.hash.slice(1);
}
if (window.location.replace){ 
window.location.replace(url + escapedHash);
} else {
window.location.href = url + escapedHash;
} 
} 
redirectOnLoad();
</script>
</head>
</html>
<!-- Body events -->
<script type="text/javascript">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken="null";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script>


<!--
...................................................................................................
...................................................................................................
...................................................................................................
...................................................................................................
-->

1个回答

soup1 = str(soup).split('url')

DuDuCaiDeFish
DuDuCaiDeFish 是的,昨天后来发现了,要先string一下才能截,谢谢~
8 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐