Div class 在 google chrome 网络检查器中显示为随机字符串而不是名称
Div class showing up as random string instead of name in google chrome web inspector
我正在尝试学习网络抓取的介绍教程(https://www.analyticsvidhya.com/blog/2017/07/web-scraping-in-python-using-scrapy/) and it is working with the game of thrones reddit page https://www.reddit.com/r/gameofthrones/。在教程中,它说当您检查 post 的标题时,它将显示为“
<div class = "top matter">
<p class = "title">
等但是当我检查标题时,它显示为
<a data-click-id="body" class="SQnoC3ObvgnGjWt90zD9Z" href="/r/gameofthrones/comments/bwc0te/no_spoilers_justgiving_fundraiser_for_kit/"><h2 class="yk4f6w-0 lbhQOA">[NO SPOILERS] JustGiving fundraiser for Kit Harington's charity Mencap</h2></a>
<h2 class="yk4f6w-0 lbhQOA">[NO SPOILERS] JustGiving fundraiser for Kit Harington's charity Mencap</h2>
或者例如当我尝试检查投票计数时:
<div class="s1h1p2hu-0 fIbDHO"><button class="_2k73nZrjAYiwAj9hv7K-kq" theme="[object Object]" aria-label="upvote" aria-pressed="false" data-click-id="upvote" id="upvote-button-t3_bwc0te" style="background-image: url("https://styles.redditmedia.com/t5_2rjz2/styles/postUpvoteIconInactive_6fsa07qaj5t01.png"); width: 24px; height: 24px;"></button><div class="_1rZYMD_4xY3gRcSS3p8ODO" style="color: rgb(26, 26, 27);">412</div><button class="ceU_3ot04pOVIcrrXH9fY" theme="[object Object]" aria-label="downvote" aria-pressed="false" data-click-id="downvote" style="background-image: url("https://styles.redditmedia.com/t5_2rjz2/styles/postDownvoteIconInactive_a6hsvdx3j5t01.png"); width: 24px; height: 24px;"></button></div>
我也尝试在 FireFox 中打开该页面,但出现了同样的问题。所以我知道这不是广告拦截器。
我已经试过像 Ebay 这样的另一个页面,div classes/ids 的标题稍微更具描述性,所以我不确定发生了什么。
感谢您的帮助!
页面的 HTML 标记在教程首次发布后的 2 年内发生了变化。
如果您想继续使用 2017 年的原始标记,可以使用 Wayback Machine 的页面:https://web.archive.org/web/20170725035139/https://www.reddit.com/r/gameofthrones/
下面的屏幕截图显示了教程中解释的预期标记:
我正在尝试学习网络抓取的介绍教程(https://www.analyticsvidhya.com/blog/2017/07/web-scraping-in-python-using-scrapy/) and it is working with the game of thrones reddit page https://www.reddit.com/r/gameofthrones/。在教程中,它说当您检查 post 的标题时,它将显示为“
<div class = "top matter">
<p class = "title">
等但是当我检查标题时,它显示为
<a data-click-id="body" class="SQnoC3ObvgnGjWt90zD9Z" href="/r/gameofthrones/comments/bwc0te/no_spoilers_justgiving_fundraiser_for_kit/"><h2 class="yk4f6w-0 lbhQOA">[NO SPOILERS] JustGiving fundraiser for Kit Harington's charity Mencap</h2></a>
<h2 class="yk4f6w-0 lbhQOA">[NO SPOILERS] JustGiving fundraiser for Kit Harington's charity Mencap</h2>
或者例如当我尝试检查投票计数时:
<div class="s1h1p2hu-0 fIbDHO"><button class="_2k73nZrjAYiwAj9hv7K-kq" theme="[object Object]" aria-label="upvote" aria-pressed="false" data-click-id="upvote" id="upvote-button-t3_bwc0te" style="background-image: url("https://styles.redditmedia.com/t5_2rjz2/styles/postUpvoteIconInactive_6fsa07qaj5t01.png"); width: 24px; height: 24px;"></button><div class="_1rZYMD_4xY3gRcSS3p8ODO" style="color: rgb(26, 26, 27);">412</div><button class="ceU_3ot04pOVIcrrXH9fY" theme="[object Object]" aria-label="downvote" aria-pressed="false" data-click-id="downvote" style="background-image: url("https://styles.redditmedia.com/t5_2rjz2/styles/postDownvoteIconInactive_a6hsvdx3j5t01.png"); width: 24px; height: 24px;"></button></div>
我也尝试在 FireFox 中打开该页面,但出现了同样的问题。所以我知道这不是广告拦截器。
我已经试过像 Ebay 这样的另一个页面,div classes/ids 的标题稍微更具描述性,所以我不确定发生了什么。
感谢您的帮助!
页面的 HTML 标记在教程首次发布后的 2 年内发生了变化。
如果您想继续使用 2017 年的原始标记,可以使用 Wayback Machine 的页面:https://web.archive.org/web/20170725035139/https://www.reddit.com/r/gameofthrones/
下面的屏幕截图显示了教程中解释的预期标记: