We look for an element in HTML,
just like locating a city.
We have two ways to find this element (city), one is CSS and the other is XPTAH.
So what is the difference between the two?
css: the form of the city | xpath: the location of the city |
---|---|
The capital of Guangdong Province | 112 degrees 57 minutes east longitude to 114 degrees 3 minutes east longitude 22 degrees 26 minutes to 23 degrees 56 minutes north latitude |
Ranked third among first-tier cities | The city on the right of Foshan |
find_element_by_css_selector("[class=“Guangdong_capital”]") | find_element_by_xpath("//span[@id=‘Foshan’]/City") |
- With this information, you can accurately locate Guangzhou
- When you understand the positioning ideas in the table, you actually understand the difference between css and xpath