如何从美丽的群岛中提取Li?
我知道这个问题似乎很基本,但我似乎无法从给定的ULS中提取LI和文本。
https://solar.world.org/reuse/aluminum.foil
这是这里我想提取的URL。我尝试使用Find_all作为UL,但这给了我一个奇怪的回报结果,我无法使用它来从LI中提取任何文本。
从理论上讲,此代码应该起作用。
page = requests.get('https://solar.world.org/reuse/Aluminum.Foil')
soup = BSoup(page.content, 'html.parser')
for i in soup.find_all('ul'):
for j in i.find_all('li'):
print(j.text)
但不是。
I know the question may seem very basic but I can't seem to extract the li and the text from the given uls.
https://solar.world.org/reuse/Aluminum.Foil
Here is the url I am trying to extract. I have tried using find_all for ul but that gives me a weird return result and I can't use it to extract any text from the li.
In theory this code should work.
page = requests.get('https://solar.world.org/reuse/Aluminum.Foil')
soup = BSoup(page.content, 'html.parser')
for i in soup.find_all('ul'):
for j in i.find_all('li'):
print(j.text)
but its not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该页面的格式不好(不是您的错)。使用更好的解析器来解析它:
The page has very bad formatting (not your fault). Use a better parser to parse it: