【发布时间】:2017-07-29 13:02:18
【问题描述】:
我正在尝试抓取包含以下 html 代码的网站:
<div class="content-sidebar-wrap"><main class="content"><article
class="post-773 post type-post status-publish format-standard has-post-
thumbnail category-money entry" itemscope
itemtype="http://schema.org/CreativeWork">
这包含我感兴趣的数据...我尝试使用 BeautifulSoup 对其进行解析,但返回如下:
<div class="content-sidebar-wrap"><main class="content"><article
class="entry">
<h1 class="entry-title">Not found, error 404</h1><div class="entry-content
"><p>"The page you are looking for no longer exists. Perhaps you can return
back to the site's "<a href="http://www.totalsportek.com/">homepage</a> and
see if you can find what you are looking for. Or, you can try finding it
by using the search form below.</p><form
action="http://www.totalsportek.com/" class="search-form"
itemprop="potentialAction" itemscope=""
itemtype="http://schema.org/SearchAction" method="get" role="search">
# I've made small modifications to make it readable
漂亮的汤元素不包含我想要的代码。我对html不太熟悉,但我假设这会调用一些返回数据的外部服务..?我读过这与 Schema 有关。
无论如何我可以访问这些数据吗?
【问题讨论】:
-
你想从 HTML 代码中得到什么?
-
一个 html 表格。尝试直接解析表返回 None
-
嗯,我还是不明白,您想从哪个网站获取信息?如果信息是由 JavaScript 构建的,
requests将不起作用。
标签: python html beautifulsoup schema