用python scrape刮擦 - 我需要从同一标签中返回所有值
我尝试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扩展
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只有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()