Im trying to figure out how i would extract the data-id from something like
<div class="tweet-text" data-id="1091362563202396165">
dir="ltr" href="h" rel="nofollow noopener" target="_blank" title=.html">cnbc.com/2019/02/01/non…</a>
</div>
I've tried select('.data-id') also d.get_text('data-id') , d.match('data-id'). I'm trying to extract the actual value in data-id, the number.... Thanks for your help. I'll keep trying in the mean time...
You can use a search query of attrs={"data-id": True} to find elements that have a value for data-id.
for item in soupdata.find_all(attrs={"data-id": True}):
print (item['data-id'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With