Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # A>B means the B elements where A is the parent element.
- dietary_attrs = element.find_elements(By.CSS_SELECTOR, "div[class*='DietaryAttributes']>span")
- # if there aren't any, then `dietary_attrs` will be None and `if` block won't work
- # but if there are any dietary attributes, extract the text from them
- if dietary_attrs:
- dietary_attrs = [attr.text for attr in dietary_attrs]
- else:
- # set the variable to None if there aren't any dietary attributes found.
- dietary_attrs = None
Advertisement
Add Comment
Please, Sign In to add comment