该网站是否限制了我可以查看的结果的几页?

我正在尝试网络刮擦Foundation.App中的所有可用NFT。为此,我去了此网页: https://foundation.app/browse/nfts

我检查了网站拨打的电话的网络选项卡,到目前为止,我已经能够复制呼叫并获得前20页的结果。我遇到的问题是,该网站在其余页面上没有返回结果。我知道有20页以上可用的结果。有什么方法可以获取其余页面,还是受到网站后端的限制?

我已经在r中写了我的代码,因此如果您想显示代码,如果您使用另一种编程语言对我来说,这对我来说很好,请提前道歉,我会尝试适应它)。在这些请求中,我每次都会更改“页面”参数,然后将其增加1个以获取下一页的结果。

library(httr)

headers = c( Accept = "/", Accept-Language = "en-US,en;q=0.9", Connection = "keep-alive", Content-Type = "application/json", Origin = "https://foundation.app", Referer = "https://foundation.app/", Sec-Fetch-Dest = "empty", Sec-Fetch-Mode = "cors", Sec-Fetch-Site = "same-site", User-Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", sec-ch-ua = '"Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"', sec-ch-ua-mobile = "?0", sec-ch-ua-platform = '"Windows"' )

data = '{"query":"\n    query Nfts($accountAddress: ID, $collectionAddresses: [ID], $marketAvailability: NftMarketAvailability, $distinctAssetKey: String, $sort: NftSortOption, $page: Int, $perPage: Int, $distinct: Boolean) {\n  nftsSearch(\n    accountAddress: $accountAddress\n    collectionAddresses: $collectionAddresses\n    marketAvailability: $marketAvailability\n    distinctAssetKey: $distinctAssetKey\n    sort: $sort\n    page: $page\n    perPage: $perPage\n    distinct: $distinct\n  ) {\n    items: nfts\n    counts {\n      collectionCounts\n      marketAvailabilityCounts\n      distinctCounts\n    }\n    page\n    perPage\n    totalPages\n  }\n}\n    ","variables":{"marketAvailability":null,"sort":"DEFAULT","distinct":true,"page":1}}'

res <- httr::POST(url = "https://api-v2.foundation.app/graphql", httr::add_headers(.headers=headers), body = data) 
returned.results <- fromJSON(rawToChar(res$content)) 
returned.results returned.results$data$nftsSearch$items$collection$contractType

0 个回答

  • 3 浏览
  • jkx 提出于 2024-04-20 22:57:25

相似问题