お世話になります。
pythonであるWEBサイトの値をselenium webdriverにて値を取得したいのですが、デバッグでは値を取得出来ますが、RUNさせると値を取得出来ません。コードは下記の通りです。
使用ブラウザは、chrome, webdriverもchrome用に用いています。
Webdriverは最新のブラウザに合わせています。
python
1from bs4 import BeautifulSoup 2import requests 3from selenium import webdriver 4from selenium.webdriver.support.ui import Select 5import time 6 7w = "f4" 8url = 'https://www.xxx.com/item/item_no1.html' 9driver = webdriver.Chrome(executable_path="chromedriver.exe") 10driver.get(url) 11time.sleep(1) 12element = driver.find_element_by_name("FormModel.VariationGenpinId") 13select_w = Select(element) 14select_.select_by_visible_text(w) 15html = driver.page_source 16# print(html) 17soup = BeautifulSoup(html, "lxml") 18# print(soup) 19
上記のプログラムで、デバッグ実行させたところ、取得したい「カートに入れる」が、デバッグモードでは取得出来ますが、Runされるとsoupで取得出来ませんでした。
RUNで、print(html)では、「カートに入れる」が表示さますが、print(soup)では、「カートに入れる」が取得出来ませんでした。
どのようにしたら、RUNで取得できる様になるのか教えて頂きたいです。
ご指導のほど、よろしくお願いします。
敬具
回答1件
あなたの回答
tips
プレビュー