如何使用Selenium和Python抓取动态Web内容?

时间:2019-06-21 11:32:47

标签: python selenium-webdriver selenium-chromedriver fixed

https://www.linkedin.com/learning/topics/business

我想从网页中提取动态内容    使用硒。    输出:快速Windows技巧,​​SAP业务一精要培训

   driver = webdriver.Chrome(executable_path='/home/bhanu/tutorial/tutorial/chromedriver)

   url = "https://www.linkedin.com/learning/topics/business"
   driver.get(url)
   html = driver.page_source
   soup = BeautifulSoup(html, "lxml")
   t=soup.body
   f= t.find_all('div',{'class':'ember-view'})
   h=[]
   for x in f:
       g=x.find_all('div',{'class':'init-body init-body--with-nav-bar 
                         init-body--with-secondary-nav ember-view'})
   h.append(g)
   for t in  h:
       for u in t:
           j=u.find_all('main',{'class':'init-body__main'})
           for k in j:
               a=k.find_all('div',{'class':'self-focused ember-view'})
                   for x in a:
                        s=x.find_all('div',{'class':'topics- 
                               body__search-results content-block'})

0 个答案:

没有答案