#Scrapping info from main search page try: job_id = job.find_all("li",{"class"})['data-id'] except: job_id = 'No data available' job_ids.append(job_id)
3 Réponses :
# Lets support el is the element print(el.attrs['data-id']) # will give you desired answer
htm = '<li class="result-card job-result-card result-card--with-hover-state job-card__contents--active" data-id="1946843843" data-entity-urn="urn:li:jobPosting:1946843843" data-search-id="e2f62398-982f-463e-9685-9064dfa810eb" data-tracking-id="UDB/ibIoQvCk1l54VneerA==" data-column="1" data-row="1">' soup = BeautifulSoup(htm, 'html.parser') liele = soup.find("li", {"class":"result-card job-result-card"}) liDataId = liele['data-id']