我真的很奇怪,而且處于恐慌狀態,因為我一直在使用的很多片段都有問題。這個片段曾經產生過所需的輸出,但突然間,顯示的是一個空白的輸出。
import requests, random, re
from bs4 import BeautifulSoup
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0" ,
}
url = "https://bscscan.com/token/generic-tokenholders2?m=normal&a="/span>
token = "0xe56842ed550ff2794f010738554db45e60730371"/span>。
holdersurl = str(url) str(token)
s = requests.Session()
r = requests.get( holdersurl, headers=headers)
soupblockdetails = BeautifulSoup(r.content, 'html.parser')
rowsblockdetails = soupblockdetails.findAll('table')[0].findAll('tr', limit=6)
for row in rowsblockdetails[1: ] 。
rank = row.find_all('td')[0].text[0:].strip()
地址 = row.find_all('td')[1].text[0: ].strip()
amount = row.find_all('td')[2].text[0: ].strip()
percentage = row.find_all('td')[3].text[0:]
value = row.find_all('td') [4].text[0:]
try:
calock=row.select_one("i.far.fa-file-alt.text-secondary") ['title']
calock = "Contract")
except:
calock = "Unlocked"print ("{} {}-% {:>8}) {:>23} {} {} ".format(rank, address, amount, percentage, value, calock)
先前的輸出。#--之前的作業輸出
1 0xbbda05ea467ad348212dade5c38c11910c14e83e 202, 543,296. 764175197290329227 20.77% $3,054,207.08 Unlocked
2 UniCrypt: 代幣歸屬150,000,000 15。 38% $2,261,892.00合約
3 PancakeSwap V2: BIN 17 99,217, 566. 546415684406759104 10.17% $1,496,129.47 合同
4 Binemon: BIN代幣 27,010,296.006072937294814033 2.77% $407, 295.82 合同
5 0x81da471feb4a45438053dc05e709be056ec26c39 14,865, 062 1. 52% $224,154.43 Unlocked
uj5u.com熱心網友回復:
現在試試這些代碼,你多次運行這些代碼,網站會阻止你,現在我們添加 "cookies",它將完美運行
。span class="hljs-keyword">import requests, random, re
from bs4 import BeautifulSoup
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:92.0) Gecko/20100101 Firefox/92.0" ,
}
cookies= {'session': '17ab96bd8ffbe8ca58a78657a918558'}
headers=頭檔案
cookies=cookies
url = "https://bscscan.com/token/generic-tokenholders2?m=normal&a=">
token = "0xe56842ed550ff2794f010738554db45e60730371"。
holdersurl = str(url) str(token)
s = requests.Session()
r = requests.get( holdersurl, headers=headers)
soupblockdetails = BeautifulSoup(r.content, 'html.parser')
rowsblockdetails = soupblockdetails.findAll('table')[0].findAll('tr', limit=6)
for row in rowsblockdetails[1: ] 。
rank = row.find_all('td')[0].text[0:].strip()
地址 = row.find_all('td')[1].text[0: ].strip()
amount = row.find_all('td')[2].text[0: ].strip()
percentage = row.find_all('td')[3].text[0:]
value = row.find_all('td') [4].text[0:]
try:
calock=row.select_one("i.far.fa-file-alt.text-secondary") ['title']
calock = "Contract")
except:
calock = "Unlocked"print ("{} {}-% {:>8}) {:>23} {} {} ".format(rank, address, amount, percentage, value, calock)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/323181.html
標籤:
