1

Iam trying to update the background color of the span using python advanced-htmlParser

I have html page status.html, on which iam trying to parse and updating the color of the span and this updated color should reflect when the page get loaded

# Following are the content of Status.html

<html>
<style type="text/css">
    .Table
    {
        display: table;
    }
    .Title
    {
        display: table-caption;
        text-align: center;
        font-weight: bold;
        font-size: larger;
    }
    .Heading
    {
        display: table-row;
        font-weight: bold;
        text-align: center;
    }
    .Row
    {
        display: table-row;
    }
    .Cell
    {
        display: table-cell;
        border: solid;
        border-width: thin;
        padding-left: 20px;
        padding-right: 20px;
    }
</style>

<h1>"The dns ip is: " <span id="myID"></span></h1>

    <div class="Heading">
        <div Class="Cell">
            <p>G</p>
        </div>
        <div Class="Cell">
            <p>facebook.com</p>
        </div>
        <div id="test">
            <span id="h" class="Cell">
                <p>H</p>
            </span>
            <span id="e" class="cell">
                <p>E</p>
            </span>
           <span id ="Time" class="Cell">   
                <P> </P>                
             </span>
        </div>


        <div Class="Cell">
            <p></p>
        </div>
    </div>



</html>

#Blow is the code iam trying to update the backround color of the span_Id 'h'. 

import AdvancedHTMLParser

parser = AdvancedHTMLParser.AdvancedHTMLParser()

path = "D:/Status.html"

parser.parseFile(path)
parser.getElementById('h').style.background="yellow"


Expected: The background of

H should update with the yellow color

Actual: No update is happening once after execute the script

Appreciate if any one can help on this?

1
  • Can anyone help on this to provide some idea Commented Sep 3, 2019 at 7:27

1 Answer 1

1

I used it like this:

parser.getElementById("yourElement").setAttribute("style", "background-color:yellow")
Sign up to request clarification or add additional context in comments.

1 Comment

Please be more specific why and how your solution works. Please outline the difference of your solution and maybe link some reference or documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.