Python-爬虫-针对有frame框架的页面 (抄来的,做笔记用)


Python-爬虫-针对有frame框架的页面
有的页面会使用frame 框架,使用Selenium + PhantomJS 后并不会加载iframe 框架中的网页内容。iframe 框架相当于在页面中又加载了一个页面,需要使用Selenium 的 switch_to.frame() 方法加载(官网给的方法是switch_to_frame(),但是IDE提醒使用前面的方法替代该方法)。
比如:
driver.switch_to.frame('g_iframe')
html = driver.page_source
然后结合BeautifulSoup获取网页中信息。
这次我们爬取
http://
music.163.com/#
/artist/album?id=101988&limit=120&offset=0
页面中的专辑信息,比如,图片、网址及专辑名字。