BeautifulSoup表数据提取-数据未显示 [英] BeautifulSoup table data extraction - data not showing up

查看:222
本文介绍了BeautifulSoup表数据提取-数据未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

-2使这30个字符成为基于idfk的一些最重要的信息

-2 to make this 30 characters is some top kek information based for things idfk

推荐答案

您自己发现,元素出现在页面源中,并通过AJAX请求动态加载. urllib模块(或requests)返回页面源,这就是为什么您将无法直接获取该值的原因.

As you yourself found out, the element is not present in the page source, and is loaded dynamically through an AJAX request. The urllib module (or requests) returns the page source, which is why you won't be able to get that value directly.

转到Developer Tools> Network> XHR并刷新页面.您会看到对此网址进行的AJAX请求:

Go to Developer Tools > Network > XHR and refresh the page. You'll see an AJAX request made to this url:

https://ethplorer.io/service/service.php?data=0x8b353021189375591723e7384262f45709a3c3dc

此url以JSON形式返回数据.如果您有兴趣,可以使用requests模块和内置的.json()方法从中获取Holders编号.

This url returns the data in the form of JSON. If you have a look at it, you can get the Holders number from it using requests module and the built-in .json() method.

import requests

r = requests.get('https://ethplorer.io/service/service.php?data=0x8b353021189375591723e7384262f45709a3c3dc')
data = r.json()

holders = data['pager']['holders']['total']
print(holders)
# 2346

这篇关于BeautifulSoup表数据提取-数据未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆