大家好,如标题中所概述,我想从输入type =“ hidden”获取值,但它返回'None'。是否存在获取它的方法? 提前致谢! 我期望从“ PaReq”和“ MD”中获取值
<input type="hidden" name="PaReq" value="eNpVUstuwjAQ/JWID4gfOA+jxRJtKpVKpAjooUfXOJCKJOAkJfx97RCgtXzYmd0dr2YNm73ROllr1RotYKHrWu60l2+nowmLWRBRHhJG4yAidCRgOVvpk4Afbeq8KgXxsU8B3aBtN2ovy0aAVKeneSoCGgZhBGiAUGgzTwYWY0oDjiMM6EpDKQst1gdZeG+yANRDUFVbNuYixrEtvAFozUHsm+ZYTxA6n89+bbu+ZeGryja6JKDHMMvWRbUV6/KtSJMdTjfq8r757NJkzmzcLXYzd6aAXAVsZaMFxYQTggOPjCfM3hhQz4Ms3BTi5WPlcexjO9bAwNE9NLsCjl3mLwPWY6NLdRE8smJ3BLo7VqW2FdbLewzoMfbzq3NUNdakLxKTmI2zSEYqzDgPGY/DQGZZKDPnc1/kFHNrE2U46iUdAORk0LBCNKzaRv++wC/NTqrF">
<input type="hidden" name="MD" value="djRZa0UxelQrcVc5Z0FySWJxdlg0Zz09IVoFvEENTvjwOCe_O4c2oKjmkJX--9pXJipeKnSw3qmylmi9CRNpM_VB7PE6ThiwlR89Siu7qEpUkj7rdnVJLLuXGbViF6O9akJ4lnNqj_kWEveLghKDyAxonmcKg4hSia1VyORwlDlWJ3g9wWjU0bwVvzohyEeTzagDF3f8ggFYIYWgHiJ8ceDr0XSwoFYYxOmlb09yuyCP6LBZd-k3ED8KUo7B5pomsQF3M4RFBtS_dQdBw9wGy9R1cACkzAL0w7BvwNqw5vm3xOyFL7HUGlFbhDOPpFJ8LhEsDQwr2zptI4VBhDt0rYmJkt2hAlzU2OTPGyuvXD-8zWBGI5jcwlqCcCXPlsjMzKCSnfJuFGpxkAFIkqdEGBBKJL7Lqag06OKTO7x2HQaNYmBTKVz1uYG9FE3DUl06MjH7LzBlU1mj7-Bx_YTTuA">
这是我的代码:
script = s.get('https://www.slamjam.com/on/demandware.store/Sites-slamjam-Site/en_IT/Adyen-Adyen3D',headers=headers)
bs_3d = BeautifulSoup(script_3d.text,"html.parser")
hidden_tags = bs_3d.find_all("input", type="hidden")
for tag in hidden_tags:
print(tag.value)
答案 0 :(得分:0)
您应该使用tag["value"]
而不是tag.value
。
来自documentation
属性
标签可以具有任意数量的属性。标签
<b id="boldest">
具有属性“ id”,其值是“ boldest”。您可以通过将标签视为字典来访问标签的属性:>>>tag['id'] u'boldest'