from selenium import webdriver
from lxml import etree
from time import sleep
from random import randint
url ='https://search.jd.com/Search?keyword=%E6%89%8B%E6%9C%BA&enc=utf-8&wq=%E6%89%8B%E6%9C%BA&pvid=4e03dd16c6b24f729048a28bcd2363f3'
edge = webdriver.Edge()
edge.get(url)
js='document.documentElement.scrollTop=10000'
edge.execute_script(js)#selenium滚动条的使用
sleep(randint(3,7))
html = edge.page_source
e = etree.HTML(html)
prices = e.xpath('''//div[@class='gl-i-wrap']/div[@class='p-price']/strong/i/text()''')
names = e.xpath('''//div[@class='gl-i-wrap']/div/a[@target='_blank']/em/text()''')for name,price inzip(names,prices):print('手机款式名称:',name,'——————其价格为——————:',price,'元')