I want to make a discord bot, that gets certain codes from a website and posts them every day at 12am in a certain channel. I got the web scraping thing to work, but I don't know how to implement that into my discord bot, or if it's even possible. I need to know how I can send the results from the scraping as a message on discord. I made this with a Wayscript tutorial from youtube and a tutorial for unordered lists on stackoverflow:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0')
browser = webdriver.Chrome(options = options)
browser.set_page_load_timeout(30)
browser.get('https://www.pockettactics.com/genshin-impact/codes')
codes = browser.find_element_by_class_name('entry-content')
codes_element = codes.find_elements_by_tag_name('ul')
temp = codes_element[0].find_elements_by_tag_name('li')
print(temp)
browser.close()
It prints this:
[<selenium.webdriver.remote.webelement.WebElement (session="cce994f1f2ff0ba3ec16090d353a8124", element="e2ca46c2-4e26-4039-95d3-e6e3fc17ca2f")>, <selenium.webdriver.remote.webelement.WebElement (session="cce994f1f2ff0ba3ec16090d353a8124", element="0b29d818-4678-4108-9d05-6336fe0d6c8a")>]
So I think it finds the two codes listed in the elements, but I'm not sure how I can get my bot to send the contents of those results as a message.
I'm very new to web scraping, using python and making discord bots, so I have no idea what to do here and I can't find answers anywhere. I have tried a million different ways to do this but nothing works. The closest I got was some weird error as a message, so it kinda worked but it didn't send the actual contents of the element I was looking for.