【发布时间】:2018-01-18 03:57:47
【问题描述】:
我有一个下载 html 页面的 python 脚本。我正在寻找这个 div:
<data-a-target="clip-thumbnail-link"
当我检查我看到的网页上的元素时,那个 div 就在那里。但它没有出现在我的脚本中的打印语句中
from bs4 import BeautifulSoup
from urllib import urlopen
BASE_URL = "https://www.twitch.tv/lethalfrag/clips"
def get_category_links(section_url):
html = urlopen(section_url).read()
soup = BeautifulSoup(html, "lxml")
print(soup)
get_category_links(BASE_URL)
【问题讨论】:
-
听起来该元素是通过 javascript 基于某些事件(鼠标悬停、鼠标单击或简单的计时器)注入到页面内容中的。
-
您可能想了解 Selenium。
标签: python web-scraping beautifulsoup