Issue
I'm trying to use BS for the web scrapping. I can easily find the defined class, see the screen below, but it will show me the all ements, with all sizes.
Is there a way, how to filter the second argument in the DIV, which is the size? Or do I have to simply scrap all of it and then filter it? I'd like to have just this element/DIV for the size S.
Solution
You could extend your selection of elements, based on low details from your question, I just wanna point out css selectors
soup.select('div.productConfiguration__selectVariant[data-product-size="S"]')
Example
from bs4 import BeautifulSoup
html = '''
<div data-product-size="S" class="productConfiguration__selectVariant some classes">content</div>
'''
soup = BeautifulSoup(html)
soup.select('div.productConfiguration__selectVariant[data-product-size="S"]')
Answered By - HedgeHog
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.