I'm witting Python script which extract current page url by going to next page, and extract page url.
I can confirm that the browser is up and connecting to start page. But after that, Nothing will happen.
e.g) start page:
`https://www.jtb.co.jp/kokunai-hotel/list/kyoto/feature/couple_yado/?multiarea=26&dateunspecified=1&page=1`
URL I want extract is following 4 pages:
・https://www.jtb.co.jp/kokunai-hotel/list/kyoto/feature/couple_yado/?multiarea=26&dateunspecified=1&page=1
・https://www.jtb.co.jp/kokunai-hotel/list/kyoto/feature/couple_yado/?multiarea=26&dateunspecified=1&page=2
・https://www.jtb.co.jp/kokunai-hotel/list/kyoto/feature/couple_yado/?multiarea=26&dateunspecified=1&page=3
・https://www.jtb.co.jp/kokunai-hotel/list/kyoto/feature/couple_yado/?multiarea=26&dateunspecified=1&page=4
I wrote script as below.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import NoSuchElementException
import pandas as pd
from time import sleep
import time
options = Options()
driver = webdriver.Chrome('path',options=options)
pageURL = 'https://www.jtb.co.jp/kokunai-hotel/list/kyoto/feature/couple_yado/'
driver.get(pageURL)
sleep(3)
elem_urls = []
while True:
url = driver.current_url
for urls in url:
elem_urls.append(urls)
try:
next_button = driver.find_elemenent_by_class_name('f-list-paging__next')
next_button.click()
sleep(3)
except Exception:
break