我说的网站:http://www.animenewsnetwork.com/encyclopedia/anime.php?id=160
你不能通过正常的请求废弃这个网站,这是不允许的。因此,我使用硒。现在,我的问题是:
我一直在试着从“流派”领域获取文本。如您所见,在第页上,它显示如下:
Genres: adventure, comedy, science fiction
刮削的问题是,这些链接附加到它们,当我刮削数据时,我不能只刮削文本。它还向我展示了类,链接到这些流派。你知道吗
我现在的代码:
driver.get('http://www.animenewsnetwork.com/encyclopedia/anime.php?id=160')
elem = driver.find_element_by_xpath("//*")
source_codeANN = elem.get_attribute("outerHTML")
soup2 = BeautifulSoup(source_codeANN, 'html.parser')
Genre = soup2.find_all('div',{'id':'infotype-30'})
print Genre
如果您有以下HTML
您可以获得以下类型链接的值:
我建议用
Genres:
文本和join查找strong
元素的以下所有同级:演示:
请试试这个
相关问题 更多 >
编程相关推荐