简体   繁体   English

无法为网页抓取音频

[英]Unable to scrape audio for webpage

I am trying to scrape audio(under experience the sound) from 'https://www.akrapovic.com/en/car/product/16722/Ferrari/488-GTB-488-Spider/Slip-On-Line-Titanium?brandId=20&modelId=785&yearId=5447'.我正在尝试从“https://www.akrapovic.com/en/car/product/16722/Ferrari/488-GTB-488-Spider/Slip-On-Line-Titanium?品牌 ID=20&modelId=785&yearId=5447'。 I have written following code but it gives me error.我已经编写了以下代码,但它给了我错误。

driver.get('https://www.akrapovic.com/en/car/product/16722/Ferrari/488-GTB-488-Spider/Slip-On-Line-Titanium?brandId=20&modelId=785&yearId=5447')
audio_link = driver.find_element(By.XPATH,'//*[@class="container-xl"]')
print(audio_link.find_element(By.CSS_SELECTOR,'audio'))     

Hope to find a better way to scrape it.希望能找到更好的方法来刮掉它。

First of all, instead of driver.find_element(By.XPATH,'//*[@class="container-xl"]') it should be driver.find_element_by_xpath('//*[@class="container-xl"]') .首先,应该是 driver.find_element_by_xpath( driver.find_element(By.XPATH,'//*[@class="container-xl"]') driver.find_element_by_xpath('//*[@class="container-xl"]')

Also, there doesn't seem to be an audio file under the XPath //*[@class="container-xl" , if you are using Chrome, you can press Ctrl + Shift + I to locate the audio file.另外,XPath //*[@class="container-xl"下似乎没有音频文件,如果您使用的是Chrome,可以按Ctrl + Shift + I来定位音频文件。

You can simply use你可以简单地使用

driver.find_element(By.XPATH,'//audio')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM