我正在尝试使用python为我的朋友的Warframe氏族制作一个不和谐的机器人,该机器人从Warframe PC Announcements section中删除内容。 我想使用discord机器人以嵌入Discord聊天的形式发送它
这里是我尝试过的一些代码
import urllib
from bs4 import BeautifulSoup
import lxml
url = "http://forums.warframe.com/forum/2-pc-announcements/?sortby=start_date&sortdirection=desc"
from bs4 import BeautifulSoup
import requests
import lxml
sess = requests.Session()
page = sess.get(url)
page = BeautifulSoup(page.text, features="lxml")
soap = page.select('li.item', features="lxml")
print([s.find('li').text for s in soap])
虽然标题叫一件事,但问题叫另一件事。
要从有序列表中获取内容:
for item in ordered_list:
# This is where you would do things to your item
new_thing = foo(item)
return new_thing
要从有序列表中获取内容并传递索引:
for idx, item in enumerate(ordered_list):
# This is where you would do things to your item
new_thing = foo(item)
return idx, new_thing
关于您的问题的正文。您声明everything I've tried has failed
,您到底尝试了什么?
好吧,我无法告诉您如何执行此操作,我可以向您介绍有助于您解决问题的主题:
如果您提供更多信息,社区可以提供更好的答案。