Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在HTML中获取内容<;ol>;使用python从URL开始_Python_Html Lists_Discord.py_Repl.it - Fatal编程技术网

如何在HTML中获取内容<;ol>;使用python从URL开始

如何在HTML中获取内容<;ol>;使用python从URL开始,python,html-lists,discord.py,repl.it,Python,Html Lists,Discord.py,Repl.it,我正在尝试使用python为我朋友的Warframe氏族制作一个discord机器人,从中抓取内容我想使用discord bot将其作为嵌入到discord聊天中的文件发送出去 下面是我尝试过的一些代码 导入URL库 从bs4导入BeautifulSoup 导入lxml url=”http://forums.warframe.com/forum/2-pc-announcements/?sortby=start_date&sortdirection=desc" 从bs4导入BeautifulSo

我正在尝试使用python为我朋友的Warframe氏族制作一个discord机器人,中抓取内容我想使用discord bot将其作为嵌入到discord聊天中的文件发送出去

下面是我尝试过的一些代码


导入URL库
从bs4导入BeautifulSoup
导入lxml
url=”http://forums.warframe.com/forum/2-pc-announcements/?sortby=start_date&sortdirection=desc"
从bs4导入BeautifulSoup
导入请求
导入lxml
sess=requests.Session()
page=sess.get(url)
page=BeautifulSoup(page.text,features=“lxml”)
soap=page.select('li.item',features=“lxml”)
打印([s.find('li')。soap中s的文本])

虽然你的标题问了一件事,但你的问题问了另一件事

要从有序列表中获取内容,请执行以下操作:

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

至于你问题的主体。你说我试过的每件事都失败了,你到底试过什么

我不能告诉你怎么做,我可以告诉你一些有帮助的话题:


如果您提供更多信息,社区可以提供更好的答案。



这里没有代码,也没有实际问题。阅读一下@TomDalton我添加了一些代码和一个问题我修正了我的问题。