0
私たちはページの一番下まで来ると、製品ラインごとに "www.jabong.com"というウェブサイトをスクラップしようとしています。私はすべてのリンクを破棄したい。私が試しているコードは次のとおりです。python seleniumが自動的にページを追加します
from time import sleep
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def fetch_links(url, product_line_name):
chrome_options = Options()
chrome_options.add_argument("--disable-notifications")
chrome_path = r"D:\chromedriver.exe"
driver = webdriver.Chrome(chrome_path, chrome_options=chrome_options)
driver.get(url)
button="load-more-products"
while True:
element=driver.find_element_by_class_name(button).click()
driver.execute_script("arguments[0].scrollIntoView();", element)
link_list=["https://www.jabong.com/women/clothing/trousers-jeans/trousers/?source=topnav_women"]
product_line=["trousers"]
fetch_links(link_list[0],product_line[0])
ここで問題が見つかりません。私はclass_name、css_selectorでも試しましたが、それらのどれもが動作していないようです。ブラウザに自動的に製品をロードしたい
これは、これを行うための適切なアプローチではありません。スクロールすると新しい製品が表示され、これを続けるとページのデータが大きくなりすぎてクロムとセレンが遅すぎて処理できなくなるためです。それで、これでScrapyを使う方法を見つけて、セレンを使わないでください –
フレーム内の要素ですか? htmlを投稿してください。 – IamBatman