Google Playミュージックプレイリストのスクロールを自動化しようとしていますが、ピックアップしていないため、スタックオーバーフローのような通常のスクロールは機能しますが、私はGoogle Music webappが異なるものを使用していると思います。だからここに私の私のコードは、これまでで自動化Google Playミュージックの再生リストのスクロールがSeleniumのPythonで行われました
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from bs4 import BeautifulSoup
from selenium.webdriver.common.action_chains import ActionChains
profile = webdriver.FirefoxProfile(r"C:\Users\Richard\AppData\Roaming\Mozilla\Firefox\Profiles\puom7wwz.default-1468625172145")
driver = webdriver.Firefox(executable_path=r'geckodriver.exe',firefox_profile=profile)
driver.get("https://play.google.com/music/listen?u=1#/pl/AMaBXymw0YGY7Y-z1B-FdrwkDCm7WdO_kyK4x4xQqn_vZsg56-VzwjsRKaQPypMs88oIKHn4qZd5aDbFbh5ojt6DpoZZCyHgCA%3D%3D")
driver.find_element_by_id("gb_70").click()
time.sleep(2)
element = driver.find_element_by_xpath("//*[contains(text(), 'William Thomas')]").click()
time.sleep(2)
password_field = driver.find_element_by_name("password")
password_field.clear()
password_field.send_keys("IcewindDale1995%")
password_field.send_keys(u'\ue007') #unicode for enter key
time.sleep(10)
driver.get("https://stackoverflow.com/questions/44370208/clicking-on-link-through-google-with-selenium-web-driver")
#driver.find_element_by_id("gba_70").click()
source = driver.page_source
soup = BeautifulSoup(source, "html.parser")
time.sleep(10)
#driver.execute_script("document.getElementById('descriptionWrapper').focus();")
#time.sleep(10)
driver.execute_script("window.scrollTo(0, 400)")
# i = 0
# while i<1000:
# scroll = driver.find_element_by_id('descriptionWrapper').send_keys(Keys.PAGE_DOWN)
# i+=1
driver.find_element_by_id("gba_70").click()
with open('page1.html', 'w', encoding="utf-8") as fid:
fid.write(str(soup))
driver.close()
編集:
あり、そのコードとは、スクロールの撮影場所はありませんが、それはスタックオーバーフローのウェブサイト上で動作します。 誰かが解決策を持っていますか?次の
問題点は何ですか?何が起こっている? – user1767754
何も起こっていません。起こっているスクロールはありません。 – Peter
'400'よりも高い値を入力してスクロールして' begin'を 'end'にすると、2回目にスクロールしたい場合は最初の入力を変更するかもしれません。 – user1767754