url
= 'https://jd.com'
driver
.get
(url
)
input_tag
= driver
.find_element_by_id
('key')
input_tag
.clear
()
input_tag
.send_keys
('口红')
input_tag
.send_keys
(Keys
.ENTER
)
items
= driver
.find_elements_by_class_name
('gl-item')
for i
in items
:
link
= i
.find_element_by_tag_name
('a').get_attribute
('href')
name
= i
.find_element_by_css_selector
('.p-name em').text
.replace
('\n','')
price
= i
.find_element_by_css_selector
('.p-price i').text
commit
= i
.find_element_by_css_selector
('.p-commit a').text
print('name : {}\nprice : {}\nlink : {}\ncommit: {}'.format(
name
,
price
,
link
,
commit
))
break