gpt4 book ai didi

python - 从 Mixcloud 播放列表中提取 URL Python Selenium

转载 作者:行者123 更新时间:2023-12-04 08:11:25 27 4
gpt4 key购买 nike

我需要一些帮助来从 mixcloud.com 用户页面的 anchor href 标签中提取 URL。我知道页面是使用 javascript 生成的,我正在使用 selenium 来解决这个问题,我使用类似的方法与 Youtube 播放列表取得了成功,但我无法让它工作。这是我试图为其提取 url 的混合的 url。

https://www.mixcloud.com/caimanblack/


<div class="AudioCard__DetailsContainer-sc-1ltw4p1-6 euvMwc">
<div class="AudioCardTitle__Container-sc-1kxsru9-1 hGblkL">
<div class="AudioCardPlayButton__PlayButtonContainer-sc-1iib1iv-0 diYcBm AudioCardTitle__PlayButton-sc-1kxsru9-2 dDAfgc" title="Play">
<div class="AudioCardPlayButton__PlayButtonIconContainer-sc-1iib1iv-3 izFLOx">
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<title>Icon / 24 / Play Solid</title>
<path fill="#1E2337" d="M20 10.67L7.9 4 6 4.9v14.42l1.9.68L20 13.33z" fill-rule="evenodd"></path></svg></div>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" class="AudioCardPlayButton__PlayButtonRings-sc-1iib1iv-2 iIGcCU">
<circle class="ring-listened" cx="50%" cy="50%" r="22" style="stroke-dashoffset: 34.5575px; stroke-dasharray: 0px, 138.23px; stroke: rgb(243, 178, 166);"></circle>
<circle class="ring-remaining" cx="50%" cy="50%" r="22" style="stroke-dashoffset: 172.788px; stroke-dasharray: 138.23px, 0px;"></circle></svg></div>
<div class="AudioCardTitle__DetailsContainer-sc-1kxsru9-3 cTqEgM">
<a class="AudioCardTitle__PlainLink-sc-1kxsru9-0 AudioCardTitle__TitleLink-sc-1kxsru9-4 jKwuem" href="/caimanblack/93-94-dark-jungle-mix-5/">93-94 Dark Jungle Mix 5</a>
<div class="AudioCardTitle__OwnerText-sc-1kxsru9-5 gxeIb">by&nbsp;
<span class="hovercard-anchor AudioCardTitle__OwnerHovercard-sc-1kxsru9-7 cicNsQ">
<a class="AudioCardTitle__PlainLink-sc-1kxsru9-0 AudioCardTitle__OwnerLink-sc-1kxsru9-6 YOGda" href="/caimanblack/">Caiman Black</a>
这是我尝试过的,但一无所获。
for item in range(20): 
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.TAG_NAME, "body"))).send_keys(Keys.END)


mixes = driver.find_elements_by_class_name('styles__SectionContainer-obazx4-0 fKqoOc')


for mix in mixes:
link = mix.find_element_by_xpath('.//*[@class="AudioCardTitle__Container-sc-1kxsru9-1 hGblkL"]')
print(link)

最佳答案

你能试试这个吗? :

mixes = driver.find_elements_by_xpath("//a[contains(@class,'AudioCardTitle')]")
for mix in mixes:
print(mix.get_attribute("href"))

关于python - 从 Mixcloud 播放列表中提取 URL Python Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65935271/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com