I do project on Python courses. Written parser for the site using BeautifulSoup. There is a product page where to get the price you need to find the buttons and make 2 clicks (choose say the color and set of goods) in order to do this decided to use the selenium module for Python. After clicks, I get something like

<span id="j-sku-price" class="p-price">340.99</span> 

Now you need to get this price. If you pull out using BeautifulSoup, it does not receive data on clicks (just a parsit from the received address on which this field is not filled in until the clicks are made), so you need to pull it out in another way.

I found the storeText and getText commands for selenium, but I don’t understand how to apply them, people in the topics of the selenium forums throw some code in the format

storeText | //div[@class='price'] | productPrice

Which of course is not understood by the Python interpreter. Writing in a clear form for python, I get different errors for different recording options. Basically, the module does not contain the storeText and getText commands. What is the right way to get some code to get this price out of the Python environment?

  • I strongly recommend that you at least read what JavaScript is, why it is used on the web, and why some tasks are solved by pure Soup, and others only by the browser - AtachiShadow

1 answer 1

The answer is found in the English-language stackoverflow. This is how it works:

 for element in driver.find_elements_by_id("j-sku-price"): print(element.text)