Search

Shifting Point Of View

3 min read 0 views
Shifting Point Of View
tags, BeautifulSoup may still create them implicitly. But we didn't have them. The code sets soup = BeautifulSoup(html, "html.parser") then soup.title returns tag inside which exists. So it's fine. But we didn't close tags? It's okay. But I realize: we defined inside html? We didn't, but that's okay; parser will auto create. But we didn't close body, but we didn't create closing tags; but BeautifulSoup might auto close them. But we need to ensure our html has closing tags for each

etc. We did. Good. Now check: We need to ensure 'body' tag is present. We didn't have tag. BeautifulSoup will create a body tag if missing. But the 'body' tag may be created but not as a direct child of html? Usually yes. Let's check: soup.body will exist. In our code, we didn't parse the closing tags but they are auto inserted. But let's check: soup.body is not None. Thus the test should pass. Now we also need to check that 'body' tag contains

,

elements. We have them. But we need to check if

tags exist. We inserted

tags inside

sections. So yes. Now we also need to check that the 'body' tag is not empty. It will have many tags. But we might need to ensure that there is at least one

tag in body, because test only checks 'body' tag and that it has

,

. If 'body' tag contains those tags as direct children or nested inside

etc., .find_all will still find them. Ok. But we need to ensure that the tag has

,

. It does. Now we also need to ensure that the

tag has . We have. Also need to ensure contains and tags. The tag will contain them. Good. Now we also need to ensure that the page does not contain a 'style' tag. We have no
Was this helpful?

Share this article

See Also

Suggest a Correction

Found an error or have a suggestion? Let us know and we'll review it.

Comments (0)

Please sign in to leave a comment.

No comments yet. Be the first to comment!