I am working on some scraping on the web and I am trying to create a lambda function out of this.
The idea is that first I find all "td" in the BeautifulSoup variable I made (r_soup) and then I go deeper to search "a" and check the one that has "JPY" or "Depends on experience" in the text. That's the value I want:
salary = r_soup.find_all('td')
for s in salary:
if s.find('a') and 'JPY' in s.text or s.find('a') and 'Depends on experience' in s.text:
print(s.text.strip())
I have tried this:
salary = list(map(lambda s: s.text if (s.find('a') and 'JPY' in s.text) or (s.find('a') and 'Depends on experience') in s.text ,r_soup.find_all('td')))
salary
But it is not working. I don't know much about lambda functions and I have been searching on the web but to no avail. Thanks a bunch for the help!
Aucun commentaire:
Enregistrer un commentaire