1

I am stuck with a scraping problem:

So I have this html code.. and I need to get the value of the telephone number

<body>
    <p class="tel">telephone :</p>
    <p class="val">+123456789</p>
    <p class="fax">Fax :</p>
    <p class="val">+33 3 86 32 42 91</p>
    <p class="email">Email :</p>
    <p class="valeur">[email protected]</p>
</body>

How can I get the telephone number using python? I tried using bs4 but i don't know how to find the second <p> element from the element with class tel.

2
  • 1
    Can you share the code that you have made an attempt with? Commented Jan 11, 2016 at 16:38
  • i tryed some garbage code .. i think it is humiliating to paste that code. thanks anyway Commented Jan 11, 2016 at 21:46

1 Answer 1

2

Locate the telephone "label" and get the next sibling:

soup.find("p", class_="tel").find_next_sibling("p", class_="val").get_text()
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.