【发布时间】:2021-04-21 00:51:07
【问题描述】:
您好,我正在尝试使用 beautifulsoup 和 API 请求更新汇合页面的表格内容之一。
这是我的代码。我能够找到并更新 td,但无法将更新后的 td 插入到 soup 变量中。
content=requests.get(address,headers=headers).text
soup=BeautifulSoup(content,'html.parser')
for td in soup.find_all('td'):
if td == "<td> i need to update this </td>:
td.replace_with("<td>updated</td>")
我需要将更新的 td 插入到汤变量中,所以当我搜索 soup.find_all('td') 时,我可以找到更新的而不是我需要更新它 我该怎么做?
谢谢
【问题讨论】:
标签: python beautifulsoup