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

2023-03-22
前端之家小编收集整理的如何获得带有按钮的URL附加?内容,希望整理的这个开发编程问题如何获得带有按钮的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,然后返回主网页。它要花很多的钱,因为当它返回原始网站时,它必须在第一页上,然后我必须转到要抓取的那个页码。

问题答案

请尝试使用相对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

如果觉得前端之家所整理的内容很不错的话,欢迎点击下方分享按钮,转发给身边开发程序员好友。

编程问答


是否可以将 Python 程序转换为 C/C++? 我需要实现几个算法,我不确定性能差距是否足以证明我在 C/C++ 中执行它时所经历的所有痛苦(我不擅长)).我想写一个简单的算法,并根……
我想使用 NTT 进行快速平方(请参阅快速 bignum 平方计算),但即使对于非常大的数字……超过 12000 位.
C++ 标准在 3.3.2声明点\"中包含一个半著名的令人惊讶\"名称查找示例: int x = x; 这用自身初始化 x,它(作为原始类型)未初始化,因此具有不确定的值(假设它是一个自动变……
以下代码: myQueue.enqueue(\'a\'); myQueue.enqueue(\'b\'); cout << myQueue.dequeue() << myQueue.dequeue();
据我所知,写时复制不是在 C++11 中实现符合标准的 std::string 的可行方法,但是当它最近在讨论中出现时,我发现我自己无法直接支持这种说法.