python-3.x - 从从发布请求收到的 iframe 响应中解析 src 链接
问题描述
我像这样在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)
解决方案
html_doc = select_req.text
soup = BeautifulSoup(html_doc, 'html.parser')
link = soup.find('iframe').get('src')
推荐阅读
- java - Android + Apache POI 我需要阅读 .docx 并转换为文本
- c# - Xamarin Azure AD PublicClientApplicationBuilder GetAccountsAsync 返回 0
- octobercms - 我可以通过对象ID而不是索引获取记录吗
- jhipster - Jhipster 实体更改导致 liquibase 校验和验证失败错误
- javascript - 透视 JavaScript 数组
- java - 如何将输入的计算存储到内存,输入重复,输入的第一个计算添加到输入的第二个计算等等?
- java - 我无法打印转换字符串的值
- vue.js - Vue.js 错误:无法读取未定义的属性“过滤器”
- python - Scipy TypeError:在优化中使用 dogleg 时,只能将 size-1 数组转换为 Python 标量,为什么?
- javascript - 单个 onChange 仅用于一种形式