I created an application to automatically get information about a certain site. https://github.com/jajaja12345-code I will write it as a memorandum of what I checked at that time.
When there is a space between the class names
<p class = "servings_for yield">
When things like
find_element_by_css_selector("servings_for yield")
Then an error will occur.
Therefore, write as follows
find_element_by_css_selector(".servings_for.yield")
Do it with find_elements
.
elements, not elements
reference [What to do when WebElement object is not iterable appears in selenium](http://www.asnm4.com/2018/11/selenium%E3%81%A7webelement-object-is-not-iterable%E3%81% 8C% E5% 87% BA% E3% 82% 8B% E3% 81% A8% E3% 81% 8D% E3% 81% AE% E5% AF% BE% E5% 87% A6% E6% 96% B9% E6% B3% 95 /)
Check if it exists with a try statement and catch NoSuchElementException with except (Multiple exceptions can be described)
reference Basics of Python and Selenium Python exception handling (try, except, else, finally)
Use pass statement
reference I want to define a function that does nothing
driver.implicitly_wait(10)
Wait 10 seconds to find each element of the driver.
reference [Python] implicitly_wait ... Set the waiting time until the specified driver element is found
I want to be able to input from my smartphone.
Recommended Posts