Search code examples
htmlpython-3.xweb-scrapingrequesturllib

HTML being changed in, footer being placed inside the body when coded outside the body


I'm just doing a personal project and learning about HTML. I've got a basic HTML script (full)

<!doctype html>
<html lang="en">
    <head>
        <title>Frame_Test</title>
    </head>
    <body>
        <p>PARAGRAPH FRAME</p>
    </body>
    <footer>
        <p>Paragraph Footer</p>
    </footer>
</html>

When i run the script, the footer is moved inside the body <body><footer></footer></body>. However when i do a fp = urllib.request.urlopen(url)it shows the footer being outside the body. If the footer is outside the body the xpaths don't work. How do i fix this? I want to be shown the exact HTML code that is going to be shown to the user.

I am using HTML 5. I have also used the request.get tool too and the results are the same

Edit: When you compile the HTML file you are given this.

<!doctype html>
    <html lang="en">
        <head>
            <title>Frame_Test</title>
        </head>
        <body>
            <p>PARAGRAPH FRAME</p>
        <footer>
            <p>Paragraph Footer</p>
        </footer>
        </body>

    </html>`

Solution

  • That's on purpose. The <footer> tag can only be used inside the <body> tag.