各位大大好:
小弟最近在练习用selenium进行网络爬虫,正好以Agoda网站为目标爬取台北市所有的
饭店名称(先爬取第一页为主,然后换页),结果显示的结果不但没有换页,而且饭店名称
只有印出四间。
以下是我的程式码与报错资讯,麻烦各位帮我瞧瞧哪里写错了,谢谢。
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import re
import time
from bs4 import BeautifulSoup
browser = webdriver.Chrome()
browser.get('https://www.agoda.com/zh-tw/pages/agoda/default/DestinationSearchResult.aspx?asq=Ss5PXyh1QUNdFOc4lzIDoPF%2BRvl%2F2EATmGvZScKd0zV2eryqVzxofG%2BmP16PwMJIhn6ZcBnwwPWMfnG%2FN94g7S8wUgfCFrPYXSVII0eHKcYuF%2FAeuf3Ntuv%2F3UlVEtcg%2Fh%2Fe4idk67OoEy6KdHwUNum%2B3QacrQMDUE7JkJAfzu3W62o9bPbdQ8KZcSPiCaH9nxv16MZrgiZOZki0W6H9dQ%3D%3D&city=4951&cid=-999&tick=636413477452&isdym=true&searchterm=%E5%8F%B0%E5%8C%97&txtuuid=f685547f-5b5a-4507-bace-845d3ca9b6f0&pagetypeid=1&origin=TW&tag=&gclid=&aid=130243&userId=6
5319270-7a97-4746-8d25-e53b463a0ddf&languageId=20&sessionId=vlmk2yavkgwagnc4g2g12nii&storefrontId=3¤cyCode=TWD&htmlLanguage=zh-tw&trafficType=User&machineName=HK-AGWEB-2E07&cultureInfoName=zh-TW&textToSearch=%E5%8F%B0%E5%8C%97&guid=f685547f-5b5a-4507-bace-845d3ca9b6f0&checkIn=2017-09-27&checkOut=2017-09-28&los=1&rooms=1&adults=2&children=0&childages=&ckuid=65319270-7a97-4746-8d25-e53b463a0ddf&sort=agodaRecommended')
soup = BeautifulSoup(browser.page_source)
for ele in soup.select('.hotel-name span'):
print(ele.text)
browser.find_element_by_id("paginationNext").click()
===========================================================================
艺宿商旅 - 板桥馆 (Yi Su Hotel)
国联大饭店 (United Hotel)
漾馆时尚温泉旅馆 (Aquabella Hotel)
馥兰朵乌来渡假酒店 (Volando Urai Spring Spa & Resort)