【发布时间】:2018-09-22 19:15:20
【问题描述】:
我正在尝试从 DnDbeyond 抓取数据。我正在使用 Beautifulsoup 和 python,并且已经能够通过使用“Div”标签和“Find_all”类获得一些我需要的信息,但我似乎无法从这些包含字符统计信息的格式化块中找到信息.
<div class="ct-skills__col--skill">Animal Handling</div>
我应该可以搜索soup.find("div", {"class": "ct-skills__col--skill"})
对吗?
这就是我当前的代码的样子。
from bs4 import BeautifulSoup
import requests
resp = requests.get('https://www.dndbeyond.com/characters/4741434')
soup = BeautifulSoup(resp.text, 'lxml')
divTag = soup.find_all("div", {"class": "container"})
这让我感动
[<div class="container">
<div class="main content-container" id="content">
<section class="primary-content" role="main">
<div data-character-endpoint="/character/4741434/json" data-character-id="4741434" data-read-only="true" id="character-sheet-target"></div>
<script src="/Content/1-0-482-0/React/CharacterTools/dist/characterSheet.bundle.min.js" type="text/javascript"></script>
</section>
</div>
</div>]
我知道我的信息在“字符表目标”下,但我不知道如何在其中获取信息/类。
很抱歉,如果这是我不知道如何解释这一点的 rambely。
【问题讨论】:
-
此页面在客户端使用Javascript生成页面。
-
好吧,有没有办法获取这些信息?
-
想通了。不得不使用 Selenium 来抓取我猜想的 javascript 内容。
标签: python beautifulsoup