用python scrape刮擦 - 我需要从同一标签中返回所有值

发布于 2025-02-11 18:05:07 字数 2607 浏览 0 评论 0 原文

我尝试scrape https://cryptorank.io/fundraising-platforms : 我需要一个区块链信息: 在SCRAPY SHELL中,我使用代码:

fetch('https://cryptorank.io/fundraising-platforms')
**FIRST EDIT** they changed .bZTNAB to .iyBlmE
response.css('.iyBlmE').get()

返回:

'<td class="blockchain-icon__BlockchainIconWrapper-sc-1jbqlsx-1 bZTNAB"><a title="Solana" class="blockchain-icon__BlockchainIcon-sc-1jbqlsx-0 lktuZD"></a><a href="
/blockchains/solana"><img alt="Solana icon" class="styled__LinkIcon-sc-1dw6qb0-5 jpwBjO" src="https://img.api.cryptorank.io/coins/icon.solana1606979093056.png"></a
><a title="Ethereum" class="blockchain-icon__BlockchainIcon-sc-1jbqlsx-0 cvIVGk"></a><a href="/blockchains/ethereum"><img alt="Ethereum icon" class="styled__LinkIc
on-sc-1dw6qb0-5 jpwBjO" src="https://img.api.cryptorank.io/coins/icon.ethereum1524754015525.png"></a><a title="BNB" class="blockchain-icon__BlockchainIcon-sc-1jbql
sx-0 eJkzMZ"></a><a href="/blockchains/bnb"><img alt="BNB icon" class="styled__LinkIcon-sc-1dw6qb0-5 jpwBjO" src="https://img.api.cryptorank.io/coins/icon.binance%
20coin1645029040254.png"></a><a title="Polygon" class="blockchain-icon__BlockchainIcon-sc-1jbqlsx-0 dYSgum"></a><a href="/blockchains/matic-network"><img alt="Poly
gon icon" class="styled__LinkIcon-sc-1dw6qb0-5 jpwBjO" src="https://img.api.cryptorank.io/coins/icon.polygon1624610763534.png"></a><a title="Huobi Token" class="bl
ockchain-icon__BlockchainIcon-sc-1jbqlsx-0 cyYEun"></a><a href="/blockchains/huobi-token"><img alt="Huobi Token icon" class="styled__LinkIcon-sc-1dw6qb0-5 jpwBjO" 
src="https://img.api.cryptorank.io/coins/icon.huobi-token1524754545762.png"></a></td>'

但是我需要所有名称区块链,此信息在此部分&lt; a title =“ polygon” class =“ blockchain-icon __blockchainicon-sc-1jbqlsx-0 dysgum”&gt ;&lt;/a&gt; ,如果我尝试:

response.css(".iyBlmE a::attr(title)").get()

仅返回'solana',但我需要所有区块链。

编辑添加一些图像以解释更好: 如果我使用 response.css(“。iyblme a :: attr(title)”)

。 /I.sstatic.net/liiso.png“ rel =“ nofollow noreferrer”>使用selectorgadget扩展

图像检查员网站

run命令

I try scrape https://cryptorank.io/fundraising-platforms:
I need a blockchain information:
In scrapy shell I use the code:

fetch('https://cryptorank.io/fundraising-platforms')
**FIRST EDIT** they changed .bZTNAB to .iyBlmE
response.css('.iyBlmE').get()

And return:

'<td class="blockchain-icon__BlockchainIconWrapper-sc-1jbqlsx-1 bZTNAB"><a title="Solana" class="blockchain-icon__BlockchainIcon-sc-1jbqlsx-0 lktuZD"></a><a href="
/blockchains/solana"><img alt="Solana icon" class="styled__LinkIcon-sc-1dw6qb0-5 jpwBjO" src="https://img.api.cryptorank.io/coins/icon.solana1606979093056.png"></a
><a title="Ethereum" class="blockchain-icon__BlockchainIcon-sc-1jbqlsx-0 cvIVGk"></a><a href="/blockchains/ethereum"><img alt="Ethereum icon" class="styled__LinkIc
on-sc-1dw6qb0-5 jpwBjO" src="https://img.api.cryptorank.io/coins/icon.ethereum1524754015525.png"></a><a title="BNB" class="blockchain-icon__BlockchainIcon-sc-1jbql
sx-0 eJkzMZ"></a><a href="/blockchains/bnb"><img alt="BNB icon" class="styled__LinkIcon-sc-1dw6qb0-5 jpwBjO" src="https://img.api.cryptorank.io/coins/icon.binance%
20coin1645029040254.png"></a><a title="Polygon" class="blockchain-icon__BlockchainIcon-sc-1jbqlsx-0 dYSgum"></a><a href="/blockchains/matic-network"><img alt="Poly
gon icon" class="styled__LinkIcon-sc-1dw6qb0-5 jpwBjO" src="https://img.api.cryptorank.io/coins/icon.polygon1624610763534.png"></a><a title="Huobi Token" class="bl
ockchain-icon__BlockchainIcon-sc-1jbqlsx-0 cyYEun"></a><a href="/blockchains/huobi-token"><img alt="Huobi Token icon" class="styled__LinkIcon-sc-1dw6qb0-5 jpwBjO" 
src="https://img.api.cryptorank.io/coins/icon.huobi-token1524754545762.png"></a></td>'

But I need all name blockchain and this information is in this part <a title="Polygon" class="blockchain-icon__BlockchainIcon-sc-1jbqlsx-0 dYSgum"></a>, if I try:

response.css(".iyBlmE a::attr(title)").get()

Return only 'Solana' but I need all blockchains.

EDIT Add some images to explain better:
If I use response.css(".iyBlmE a::attr(title)").getall() return a list with all itens of the column blockchain in.

Image get .css using SelectorGadget extension

Image inspector the site

Run commands

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦言归人 2025-02-18 18:05:07

只有solana图标具有 bztnab 类。其余的都是不同的。

我会选择下面的代码段。

response.css('div [class^=“ blockchain-icon”] a :: attr(title))。getall()

Only the Solana icon has the bZTNAB class. The rest all has different ones.

I'd go with the code snippet below.

response.css('div[class^="blockchain-icon"] a::attr(title)).getall()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文