【发布时间】:2020-03-25 12:46:55
【问题描述】:
我正在尝试从此website 获取内容;为此,我编写了以下代码:
source = requests.get(justwatch+pelicula,headers=headers)
source_content = source.content
soup2 = BeautifulSoup(source_content,'html.parser')
soup2.find_all('div', class_='price-comparison__grid__row__element')
但是我什么也没做,因为 find_all() 和 find()functions 返回 None。
我在这里错过了什么?
【问题讨论】:
-
你看过“view-source:justwatch.com/es/pelicula/la-vida-es-bella”吗?您将看到页面实际上是动态生成的,因为大多数 HTML 内容不存在。因此,您将无法以这种方式获取内容,因为这样的请求不会执行页面上的脚本。您需要考虑使用 selenium 之类的工具,以便使用浏览器访问页面并执行脚本。
标签: python html beautifulsoup python-requests