-
-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathmain.py
More file actions
17 lines (11 loc) · 505 Bytes
/
Copy pathmain.py
File metadata and controls
17 lines (11 loc) · 505 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python3
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://quotes.toscrape.com/js/")
elements = driver.find_elements_by_xpath('//div[@class="quote"]')
for item in elements:
print('text:', item.find_element_by_class_name('text').text[:20] + ' ...')
print('author:', item.find_element_by_class_name('text').text)
all_tags = item.find_elements_by_class_name('tag')
print('tags:', ', '.join(tag.text for tag in all_tags))
print('-----')