使用SeleniumPython修改网站的InnerHTML



我想修改diigo.com网站的innerHTML,我有以下html代码

HTML = """
4 Methods to Make Bitcoin for Totally free?
<img src=" https://topcryptofaucets.com/img/logo.png" alt="" width="450" height="250" />
know more|for more information}.</p>
<p>1: Try Taps</p>
<p>Faucets are the simplest way associated with earning Bitcoin on the internet. Since it demands no deep understanding of crypto currencies, you will get started without any kind of worries. All a person need to do is have the valid email deal with and some time for you to invest.</p>
<p>The Method:</p>
<p>own your current rewards and increasing your balance.</p>
<p>two: Check out Paid-to-Click Internet sites</p>
associated with the revenue goes into the pockets of the people who view these ads.</p>
<p>3: Enjoy Browser Games</p>
<p>If you are a gamer and spend hours playing your preferred games online, you should earn money coming from this activity. Several browser-based games permit you to generate money in Bitcoin while playing and having fun.</p>
<p>Even though it's not the boring activity like watching videos or perhaps ads, the rewards will be typically the same. So, a person should have a look at this method as properly.</p>
<p>4: Get Involved in Mining</p>
<p>Should you be interested in mining, there is a good possibility which you didn't put in enough work. Since a lot of people don't recommend mining regarding earning crypto foreign currency anymore, be sure you acquire a rig 1st. Second, you should be prepared to pay high-energy bills. But the method we intend to talk about will be quite basic low-cost. In fact, you don't have to spend a dime. The majority of miners usually are scammers. Therefore, an individual should try this technique.</p>
A few check out more details about upon <a href=" https://topcryptofaucets.com"> bitcoin faucets</a>
"""

我尝试了以下代码,但没有任何效果

element = driver.find_element(By.XPATH, '//div[contains(@id,"tinymce")]')
driver.execute_script(f"arguments[0].innerHTML = {HTML}", element)
driver.execute_script(f"arguments[0].innerHTML = '{HTML}'", element)
driver.execute_script('document.getElementsById("react-tinymce-0").setAttribute("innerHTML", arguments[0]);',HTML)

我一直在获取

selenium.common.exceptions.JavascriptException: Message: javascript error: Invalid or unexpected token

寻找解决方案

driver.execute_script("arguments[0].innerHTML = arguments[1]", element, HTML)

最新更新