我用python这样的数据发出发布请求
select_req = req.post('https://www.example.com/payment/', data=data)
print(select_req.text)
此输出
<iframe class="paymentFrame" src="https://www.google.com/hpp/pay.shtml" width="100%" height="400" scrolling="yes" frameborder="no"></iframe>
我想解析src链接并将其保存到parsed_link
print(parsed_link)
答案 0 :(得分:0)
html_doc = select_req.text
soup = BeautifulSoup(html_doc, 'html.parser')
link = soup.find('iframe').get('src')
答案 1 :(得分:0)
我希望CSS类选择器是更快的方法
soup = BeautifulSoup(select_req.text, 'html.parser')
parsed_link = soup.select_one('.paymentFrame')['src']