【发布时间】:2021-08-08 12:30:00
【问题描述】:
所以我试图通过一个带有 selenium (python) 的不和谐 webhook 在这个 website 中发送这个 value。我怎么做?这是我到目前为止编写的代码:from selenium import webdriver
from discord_webhook import DiscordWebhook
from selenium.webdriver.common import service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
#Import service=service
service=Service("./chromedriver")
#Chrome options :)
chrome_options = Options()
chrome_options.add_argument("no-sandbox")
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-dev-shm-usage")
chrome_options.add_argument("user-data-dir=./user-data")
#Running chrome
driver = webdriver.Chrome(service=service, options=chrome_options)
driver.get('https://www.coindesk.com/price/dogecoin')
price = driver.find_element_by_xpath('//*[@id="export-chart-element"]/div/section/div[2]/div/div/div/div/div').click()
price = driver.find_element_by_xpath('//*[@id="export-chart-element"]/div/section/div[2]/div/div/div/ul/li[3]').click()
price_send = driver.find_element_by_xpath('//*[@id="export-chart-element"]/div/section/div[1]/div[1]/div[2]/div').click()
#driver.quit()
#Send it through discord webhook
webhook = DiscordWebhook(url='https://discord.com/api/webhooks/844456788626505738/s53WWXxYdBRtjLsAw95zT99vcYJf4-Z7dGopRcCInywi3TCrSs11KYvgCEGQ84xhello', content='Price: '.format(price_send))
response = webhook.execute()
【问题讨论】:
标签: python selenium discord webhooks