Python爬取携程酒店信息

代码

from selenium import webdriver
from time import sleep
import xlwt  # 进行excel操作
#谷歌驱动 告诉电脑在哪打开浏览器
driver=webdriver.Chrome(executable_path="D:/chromedriver.exe")
#打开网页
driver.get("https://hotels.ctrip.com/?allianceid=4897&sid=798178&bd_vid=8152353566163309773")
#通过xpath点击搜索
driver.find_element_by_xpath("//*[@id='btnSearch']").click()
driver.implicitly_wait(20)#隐式休息20s 登录携程

names=[]
prices=[]
addresses=[]
percents=[]
peoples=[]
for i in range(1,11):
    for j in range(1,26):
        name=driver.find_element_by_xpath("//div[@id='hotel_list']/div["+str(j)+

你可能感兴趣的:(爬虫,Python,爬虫)