Search code examples
pythonseleniuminnerhtml

Modify InnerHTML of a site using Selenium Python


I want to modify the innerHTML of diigo.com site, i have the following html code

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>
"""

I tried the following codes, but nothing worked

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)

All the time iam getting

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

Looking for a solution


Solution

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