如何获得带有按钮的URL附加?

我正在抓捕该网站Click here,这是每个记录中使用Java脚本打开Spotify页面的按钮。我想使用python获取该Spotify页面的URL。我使用了 Beautiful-soup 来抓取其他内容,但是找不到找到该网址的方法。请任何人可以告诉我该怎么做。

已编辑:

我正在尝试这个。

browser1.find_element_by_xpath('/html/body/div[1]/div[3]/div/div/div[1]/div/div[3]/button').click()
link = '{}'.format(browser1.current_url)
browser1.back()

首先,我单击按钮转到该页面,然后获取url,然后返回主网页。它要花很多的钱,因为当它返回原始网站时,它必须在第一页上,然后我必须转到要抓取的那个页码。

shaliang8 回答:如何获得带有按钮的URL附加?

请尝试使用相对xpath尝试以下解决方案

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By


driver = webdriver.Chrome(executable_path=r"chromedriver.exe")
driver.maximize_window()

driver.get("https://playlists.bubbleapps.io/playlists")
print driver.current_url

element=WebDriverWait(driver,20).until(EC.visibility_of_element_located((By.XPATH,"//div[@class='bubble-element GroupItem group-item entry-1']//button[@class='fa fa-spotify inner-element bubble-element clickable-element']")))
element.click()
#     print(elements)
# driver.find_element_by_xpath("//div[@class='bubble-element GroupItem group-item entry-1']//button[@class='fa fa-spotify inner-element bubble-element clickable-element']").click()
print driver.current_url

输出:

https://playlists.bubbleapps.io/playlists
https://open.spotify.com/playlist/5rl5QaWjWtEPv9a057w3qc
本文链接:https://www.f2er.com/3165441.html

大家都在问