feyZ1g
feyZ1g

Reputation: 62

Scraping specific attribute in tr tag

allId=soup.find_all("tr","data-id")

HTML Code

I just take data-id's values. How can I scrape these tags?

Upvotes: 1

Views: 446

Answers (1)

KunduK
KunduK

Reputation: 33384

To fetch value of data-id try this.

allId=soup.find_all("tr",attrs={"data-id" : True})
for item in allId:
    print(item['data-id'])

You can also use css selector.

allId=soup.select("tr[data-id]")
for item in allId:
    print(item['data-id'])

Upvotes: 1

Related Questions