Python 美化组无属性';获取';

Python 美化组无属性';获取';,python,python-3.x,beautifulsoup,python-requests,Python,Python 3.x,Beautifulsoup,Python Requests,试图制作漫画下载器。到现在为止,一直都还不错。但是我太累了,因为我已经干了一整天了 import requests from bs4 import BeautifulSoup title = input("Title: ") chapter = input("Chapter: ") result = requests.get("http://www.mangapanda.com/{}/{}".format(title, chapter

试图制作漫画下载器。到现在为止,一直都还不错。但是我太累了,因为我已经干了一整天了

import requests
from bs4 import BeautifulSoup

title = input("Title: ")
chapter = input("Chapter: ")
result = requests.get("http://www.mangapanda.com/{}/{}".format(title, chapter))
src = result.content

soup = BeautifulSoup(src, "html.parser")
find = soup.find(id="selectpage").findAll('option')  # A drop down menu

for i in range(len(find)):  # Find how many options are in the drop down menu
    result2 = requests.get("http://www.mangapanda.com/{}/{}/{}".format(title, chapter, i + 1))
    src2 = result2.content
    soup2 = BeautifulSoup(src2, "html.parser")
    image = soup2.find(id="img").get('src') 
    title = soup2.find(id="img").get('alt')
    with open(title + ".jpeg", 'wb') as f:
        f.write(requests.get(image).content)
当我测试它并写下“漂白”,“4” 这给了我一个错误

image = soup2.find(id="img").get('src')
AttributeError: 'NoneType' object has no attribute 'get'
这很奇怪,因为它下载第一页

提前谢谢! 它也很早就开始工作了,它下载了所有东西,但我在这里和那里修改了几行,其余的我都不知道。。我太笨了。

[编辑]
问题是当您执行
title=soup2.find(id=“img”).get('alt')
时,您会更改在
请求中使用的变量
title
。get(“http://www.mangapanda.com/{}/{}/{}.格式(标题,章节,i+1))
。尝试使用具有不同名称的变量。

soup2.find(id=“img”)
正在返回
None
为什么返回None?我用google inspect查看了这个网站,看到一个“id='img'”。哪个网站?你正在循环浏览一堆?使用
.get()
很好,问题是
soup2.find()
调用返回的
None
是什么标题和章节?我已经测试了title=“battle frenzy”和chapter='1',它对我有效,为什么它没有返回?我用google inspect查看了这个网站,我看到一个“id='img'”。如果你正确使用标题和章节,它不会返回任何内容。我用title=“battle frenzy”和chapter='1'进行了测试,效果非常好。这可能是您正在尝试的URL的结果。你能告诉我你考过的题目和章节吗。我也试过火影忍者2。因为这些章节的页数最少。