How do I change HTML code to dictionary?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MaxPicAxe
    New Member
    • Apr 2015
    • 1

    How do I change HTML code to dictionary?

    How can I change HTML into a dictionary.
    So what I mean is I have some html code...
    Code:
    <center> <div id="header-content">
    			<div id="header-content-left">
    				<a href="index.html" target="_top"><img src="header-image.jpg" id="header-image" alt="Pager"></img><a/>
    			</div>
    			<div id="header-content-right">
    				<a href="create.html" target="_top"><button id="header-content-right-cp">
    					<p style="font-family:Calibri; font-size:20px; text-align:center;"> Create </p>
    				</button></a>
    				<button id="header-content-right-si">
    					<p style="font-family:Calibri; font-size:20px; text-align:center;" onclick="login()"> Login </p>
    				</button>
    				<button id="header-content-right-so">
    					<p style="font-family:Calibri; font-size:20px; text-align:center;" onclick="logout()"> Logout </p>
    				</button>
    				<div id="header-content-right-pr">
    					<a href="account.html" target="_top"><p style="margin-top:7px; font-family:Calibri; font-size:18px; text-align:center;"> kMcMaxPicAxeYT991 </p></a>
    				</div>
    			</div>
    			<div id="header-content-right-phone">
    				
    			</div>
    		</div> </center>
    and I want it to look like a dictionary...
    Code:
    {"center":
        {
        "div id="header-content"":
            {
            "div id="header-content-left":
                {
                "a href="index.html" target="_top":
                    {
                    "img src="header-image.jpg" id="header-image"": None
                    }
                }
            "div id="header-content-right"":
                {
                "a href="create.html" target="_top"":
                    {
                    "button id="header-content-right-cp"":
                        {
                        "p style="font-family:Calibri; font-size:20px; text-align:center;"": "Create"
                        }
                    }
                "button id="header-content-right-si"":
                    {
                    "p style="font-family:Calibri; font-size:20px; text-align:center;" onclick="login()"": "Login"
                    }
                "button id="header-content-right-so"":
                    {
                    "p style="font-family:Calibri; font-size:20px; text-align:center;" onclick="logout()"": "Logout"
                    } 
                "div id="header-content-right-pr"":
                    {
                    "a href="account.html" target="_top"":
                        {
                        "p style="margin-top:7px; font-family:Calibri; font-size:18px; text-align:center;"": "kMcMaxPicAxeYT991"
                        }
                    }
                }
            "div id="header-content-right-phone"": None
            }
        }
    }
    Of course I can't just do it myself because different html will be entered each time.
    Thanks for the help.
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    Once you get deeper than a dictionary of dictionaries you should be using SQL IMHO, which can be used to find a match on multiple fields if that is what you want to do. See this link for starters http://zetcode.com/db/sqlitepythontutorial/

    Comment

    Working...