Pass Variable In Soup.find() Method - Beautifulsoup Python
Currently, I'm searching for elements using the below syntax: priceele = soup.find(itemprop='price').string.strip() Actually, the page contains element having attribu
Solution 1:
If by "two things" you refer to the name and value of the attribute, you can make them dynamic by using the **
operator to apply arbitrary keyword arguments. For example:
attrname = 'itemprop'
attrvalue = 'price'
search = {attrname: attrvalue}
priceele = soup.find(**search).string.strip()
Post a Comment for "Pass Variable In Soup.find() Method - Beautifulsoup Python"