[PYTHON] A memorandum when I tried to get it automatically with selenium

Description

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.

memorandum

There are multiple class names

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")

reference What to do when an error occurs because an element with a space cannot be acquired with by_class_name in selenium

Get multiple elements

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 /)

Catch NoSuchElementException

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)

Definition of processing that does nothing

Use pass statement

reference I want to define a function that does nothing

Set the waiting time until the element is found at once

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

Impressions

I want to be able to input from my smartphone.

Recommended Posts

A memorandum when I tried to get it automatically with selenium
I tried to automatically generate a password with Python3
When I tried to make a VPC with AWS CDK but couldn't make it
When I tried to create a virtual environment with Python, it didn't work
I tried to automatically create a report with Markov chain
I tried to get started with Hy ・ Define a class
I stumbled when I tried to install Basemap, so a memorandum
I tried to get started with Hy
[Python] A memo that I tried to get started with asyncio
I tried to make a periodical process with Selenium and Python
I tried to log in to twitter automatically with selenium (RPA, scraping)
When I get a chromedriver error in Selenium
I tried to get CloudWatch data with Python
I get a UnicodeDecodeError when running with mod_wsgi
I made a tool to automatically browse multiple sites with Selenium (Python)
I tried to make a calculator with Tkinter so I will write it
I get a UnicodeDecodeError when trying to connect to oracle with python sqlalchemy
[Outlook] I tried to automatically create a daily report email with Python
I tried to make a periodical process with CentOS7, Selenium, Python and Chrome
I tried to create a table only with Django
I tried to read and save automatically with VOICEROID2 2
I tried to get started with blender python script_Part 01
When I tried to change the root password with ansible, I couldn't access it.
I tried to draw a route map with Python
I tried to automatically read and save with VOICEROID2
I tried to get started with blender python script_Part 02
When I tried to connect with SSH, I got a warning about free space.
I tried to easily create a fully automatic attendance system with Selenium + Python
I tried a simple RPA for login with selenium
In IPython, when I tried to see the value, it was a generator, so I came up with it when I was frustrated.
I wanted to know the number of lines in multiple files, so I tried to get it with a command
I tried to automatically generate a character string to be input to Mr. Adjustment with Python
[Python] I tried to automatically create a daily report of YWT with Outlook mail
A beginner tried coloring line art with chainer. I was able to do it.
When I try to push with heroku, it doesn't work
I tried to solve a combination optimization problem with Qiskit
I want to automatically attend online classes with Python + Selenium!
I tried "How to get a method decorated in Python"
I tried to sort a random FizzBuzz column with bubble sort.
Automatically enable virtualenv when cd to a directory with zsh
I tried to divide with a deep learning language model
When I tried to create a project using Python on Docker with PyCharm, it didn't work, but it worked with Docker Compose.
I tried to automatically generate OGP of a blog made with Hugo with tcardgen made by Go
When I tried to install PIL and matplotlib in a virtualenv environment, I was addicted to it.
Since there was a doppelganger, I tried to distinguish it with artificial intelligence (laugh) (Part 2)
I made a server with Python socket and ssl and tried to access it from a browser
There was a doppelganger, so I tried to distinguish it with artificial intelligence (laughs) (Part 1)
[5th] I tried to make a certain authenticator-like tool with python
I tried to get a database of horse racing using Pandas
[2nd] I tried to make a certain authenticator-like tool with python
[3rd] I tried to make a certain authenticator-like tool with python
I wrote a script to get you started with AtCoder fast!
I get an error when trying to install maec 4.0.1.0 with pip
I tried to create a list of prime numbers with python
I tried to get a list of AMI Names using Boto3
A note I was addicted to when creating a table with SQLAlchemy
I tried to make a 2channel post notification application with Python
I tried to get started with Bitcoin Systre on the weekend
I tried to create Bulls and Cows with a shell program
I tried to make a todo application using bottle with python
[4th] I tried to make a certain authenticator-like tool with python