【发布时间】:2020-11-29 01:20:09
【问题描述】:
我尝试使用 Selenium 和 BeautifulSoup4 抓取动态加载的 href 属性。
当我查看网站源时,href 属性为空但是当我单击检查元素时,href 属性将有一个链接。表示 href 属性是动态加载的。如何提取该链接?
我正在尝试使用以下代码
def Scrape_Udemy():
driver.get('https://couponscorpion.com/marketing/complete-guide-to-pinterest-pinterest-growth-2020/')
content = driver.page_source
soup = BeautifulSoup(content, 'html.parser')
course_link = soup.find_all('div',{'class':"rh_button_wrapper"})
for i in course_link:
link = i.find('a',href=True)
if link is None:
print('No Links Found')
print(link['href'])
但是当我运行这个函数时,这是打印 []。我正在使用 Chrome 驱动程序我该如何解决这个问题。我想抓取来自 Url https://couponscorpion.com/marketing/complete-guide-to-pinterest-pinterest-growth-2020/的免费优惠券代码链接
【问题讨论】:
标签: python python-3.x selenium web-scraping beautifulsoup