0

I usually use this code:

title = soup.find(id="productTitle").get_text()

That's the Daraz website's code that I want to scrape:

<div class="pdp-product-title">
  <div class="pdp-mod-product-badge-wrapper">
    <img src="https://laz-img-cdn.alicdn.com/tfs/TB1rYuurhTpK1RjSZFMXXbG_VXa-205-48.png" class="pdp-mod-product-badge" alt="badge" />
    <span class="pdp-mod-product-badge-title">Xiaomi Redmi Note 7 Pro [4 GB RAM, 64 GB ROM ] 6.3 Inches Screen</span>
  </div>
</div>
  • Please consider beautifying your code – mmenschig Oct 21 '19 at 04:17
  • 1
    Welcome to SO! When you place a question try to add a minimum content: input sample, expected output sample, what did you try, research and where are you stacked. What did you try? just one line it is not a code... SO is not a free coding service. – David García Bodego Oct 21 '19 at 04:24

1 Answers1

1

Like this

soup.find_all("a", class_="sister")
# [<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,
#  <a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>,
#  <a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>]

taken directly from the bs4 docs

You may also see here: How to find elements by class.

CypherX
  • 7,019
  • 3
  • 25
  • 37
mmenschig
  • 1,088
  • 14
  • 22