@bot.message_handler(commands="token")
def token(message):
r = requests.get("https://poocoin.app/tokens/0x2a69c59b8b493141d9f41b8f4fa724b60cd204e0")
html = BS(r.content, 'html.parser')
token_price = html.select('.mb-1 d-flex flex-column lh-1 > .text-success')
bot.send_message(message.chat.id, "{0}".format(token_price), parse_mode='html')
UPD. Попробовал решение на selenium:
@bot.message_handler(commands="token")
def token(message):
URL = 'https://poocoin.app/tokens/0x2a69c59b8b493141d9f41b8f4fa724b60cd204e0'
driver = webdriver.Chrome()
try:
driver.implicitly_wait(5)
driver.get(URL)
print(f'Title: {driver.title!r}')
token_price = driver.find_element(By.CSS_SELECTOR, '.mb-1.d-flex.flex-column.lh-1 > .text-success')
bot.send_message(message.chat.id, "{0}".format(token_price.text),
parse_mode='html')
except:
print(traceback.format_exc())
finally:
driver.quit()
Ошибка
DevTools listening on ws://127.0.0.1:64619/devtools/browser/2d7a630e-2902-4501-8
e94-2dcce1b1ecb9
[1123/171216.156:ERROR:gl_surface_egl.cc(780)] EGL Driver message (Critical) egl
Initialize: No available renderers.
[1123/171216.157:ERROR:gl_surface_egl.cc(1374)] eglInitialize D3D11 failed with
error EGL_NOT_INITIALIZED, trying next display type
Другая ошибка после обновления драйвера хрома:
Traceback (most recent call last):
File "pars.py", line 9, in <module>
driver = webdriver.Chrome()
File "C:\Users\nigga22nd\AppData\Local\Programs\Python\Python38\lib\site-packa
ges\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "
goog",
File "C:\Users\nigga22nd\AppData\Local\Programs\Python\Python38\lib\site-packa
ges\selenium\webdriver\chromium\webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "C:\Users\nigga22nd\AppData\Local\Programs\Python\Python38\lib\site-packa
ges\selenium\webdriver\remote\webdriver.py", line 268, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\nigga22nd\AppData\Local\Programs\Python\Python38\lib\site-packa
ges\selenium\webdriver\remote\webdriver.py", line 359, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\nigga22nd\AppData\Local\Programs\Python\Python38\lib\site-packa
ges\selenium\webdriver\remote\webdriver.py", line 424, in execute
self.error_handler.check_response(response)
File "C:\Users\nigga22nd\AppData\Local\Programs\Python\Python38\lib\site-packa
ges\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not crea
ted: This version of ChromeDriver only supports Chrome version 96
Current browser version is 92.0.4515.159 with binary path C:\Program Files\Googl
e\Chrome\Application\chrome.exe
Stacktrace:
Backtrace:
Ordinal0 [0x01216903+2517251]
Ordinal0 [0x011AF8E1+2095329]
Ordinal0 [0x010B2848+1058888]
Ordinal0 [0x010D0B9D+1182621]
Ordinal0 [0x010CCA60+1165920]
Ordinal0 [0x010CA2CF+1155791]
Ordinal0 [0x010FAAAF+1354415]
Ordinal0 [0x010FA71A+1353498]
Ordinal0 [0x010F639B+1336219]
Ordinal0 [0x010D27A7+1189799]
Ordinal0 [0x010D3609+1193481]
GetHandleVerifier [0x013A5904+1577972]
GetHandleVerifier [0x01450B97+2279047]
GetHandleVerifier [0x012A6D09+534521]
GetHandleVerifier [0x012A5DB9+530601]
Ordinal0 [0x011B4FF9+2117625]
Ordinal0 [0x011B98A8+2136232]
Ordinal0 [0x011B99E2+2136546]
Ordinal0 [0x011C3541+2176321]
BaseThreadInitThunk [0x76BC339A+18]
RtlInitializeExceptionChain [0x779C9ED2+99]
RtlInitializeExceptionChain [0x779C9EA5+54]
{}
или вручную, добавляя ``` до и после кода. И вы последней правкой с ошибкой затерли код