我正试图从here获取'SALES HISTORY'的数据。
由于数据来自JavaScript,我提到了这个qazxsw poi并试图抓取数据。但是,当我运行以下代码时,新窗口不会正确显示网页。
如果你能在这种情况下建议如何获取数据,我将不胜感激。
link
我期望数据集的输出包含合同/交易哈希/卖方/买方/名称/出生日期列。
您无需刮取网站即可获取销售历史数据,因为您可以从其JSON API端点获取数据。
这是您发布的网页的终点链接:
# import libraries
import urllib.request
from bs4 import BeautifulSoup
from selenium import webdriver
import time
import pandas as pd
# specify the url
urlpage = 'https://nonfungible.com/market/history/axieinfinity'
print(urlpage)
# run Chrome webdriver from executable path of your choice
driver = webdriver.Chrome(executable_path = r'C:\Users\trey\AppData\Local\Programs\Python\Python36\Scripts\chromedriver')
您可以使用Python JSON库来提取所需的数据。要查找站点是否具有可用的JSON API,请使用浏览器开发人员控制台中的网络监视器查找对站点发出的XHR请求,并检查它是否包含您需要的数据。这比抓取HTML / JS更有意义。