-1

My code is working. But the only thing it's also returning the HTML tags. Is there anything I can add to my FOR loop to strip the HTML code?

Here's my code below.

addressNeeded = soup.find("h1", {"style": "font-size: inherit; font-weight: inherit;"})
for x in addressNeeded:
    addressList.append(x)

the outcome is:

['\n', <label class="summary-list__label">
<span itemprop="streetAddress">95 Cooks Drive</span>
</label>, '\n', <span class="summary-list__label summary-list__label--small">
<span itemprop="addressLocality">Westside</span>,
                    <span itemprop="addressRegion">NY</span>
<span itemprop="postalCode">07663</span>

I thank you in advance!

2
  • 1
    Find returns only element but your outcome shows list of elements how this is possible.Post your relevant HTML and mentioned what expected output you are looking after? Commented Feb 6, 2020 at 7:46
  • Please, provide the html code you are dealing with and the result you want to achieve. Thanks. Commented Feb 6, 2020 at 10:36

1 Answer 1

0

I believe you should change your print(x) to print(x.string) as suggested in this answer

Sign up to request clarification or add additional context in comments.

Comments

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.