【发布时间】:2019-06-26 20:13:17
【问题描述】:
我正在尝试抓取 Instagram 页面,并希望获取/访问跨度标签内的 div-标签。但我不能! Instagram 页面的 HTML 如下所示
<head>--</head>
<body>
<span id="react-root" aria-hidden="false">
<form enctype="multipart/form-data" method="POST" role="presentation">…</form>
<section class="_9eogI E3X2T">
<main class="SCxLW o64aR" role="main">
<div class="v9tJq VfzDr">
<header class=" HVbuG">…</header>
<div class="_4bSq7">…</div>
<div class="fx7hk">…</div>
</div>
</main>
</section>
</body>
我是这样的
from bs4 import BeautifulSoup
import urllib.request as urllib2
html_page = urllib2.urlopen("https://www.instagram.com/cherrified_/?hl=en")
soup = BeautifulSoup(html_page,"lxml")
span_tag = soup.find('span') # return span-tag correctly
span_tag.find_all('div') # return empty list, why ?
请同时举一个例子。
【问题讨论】:
-
请提供一个小例子,其他人可以运行并重现您的错误。
-
完成,先生,现在你可以检查了
标签: python beautifulsoup