有办法在Python的Selenium中编辑HTML吗?

huangapple go评论72阅读模式
英文:

Is there a way to edit HTML in python selenium?

问题

以下是您要翻译的内容:

"我想要修改HTML代码,类似于

  • 爬取特定网站并修改特定的HTML代码

我想要构建自己的自动化程序,但在寻找相关信息时找不到任何相关内容。"

英文:

as an example

<div>
<h5>title1</h5>
<h3>subtitle1</h3>
</div>

at

<div>
<h3>title2</h3>
<h1>subtitle2</h1>
</div>

I want to modify HTML code like

  • Crawl certain websites and modify certain HTML code

I wanted to build my own automation program, but I couldn't find anything related to it while looking for it.

答案1

得分: 0

一直以来我都使用JS通过Python的driver.execute_script命令来修改一些HTML元素。<br>
在搜索时我还注意到现在有更多的人倾向于使用BeautifulSoup来完成这些任务。<br>

英文:

I've always used JS to modify some HTML elements from python with the driver.execute_script command. <br>
While googling I've also noticed that nowadays more people tend to use BeautifulSoup for such tasks. <br>

huangapple
  • 本文由 发表于 2023年2月16日 14:03:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/75468400.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定