Pass variable in soup.find() method - Beautifulsoup Python -
Currently, I am searching for elements using the syntax given below:
< Code> priceele = soup .Find (itemprop = 'price'). String.strip ()
In fact, in the page
element contains the attribute name itemprop
with the value value
. But, let me know
The element is not required to search because the attribute is the same element with the itemprop
.
Now, what I want is itemprop = 'price'
as the soup.find ()
method because I have these two things in database Loading from Dynamic Is this possible?
If "two things" you see the name and value of the attribute, you can apply arbitrary keyword logic You can make them dynamic using the **
operator for For example:
attrname = 'itemprop' attrvalue = 'price' search = {attribute: attrvalue} priceele = soup.find (** search) .string.strip ()
Comments
Post a Comment