小编use*_*140的帖子

Python:AttributeError:'NoneType'对象没有属性'findNext'

我试图用BeautifulSoup刮一个网站,但我遇到了问题.我正在按照python 2.7中完成的教程进行操作,它中的代码完全相同,没有任何问题.

import urllib.request
from bs4 import *


htmlfile = urllib.request.urlopen("http://en.wikipedia.org/wiki/Steve_Jobs")

htmltext = htmlfile.read()

soup = BeautifulSoup(htmltext)
title = (soup.title.text)

body = soup.find("Born").findNext('td')
print (body.text)
Run Code Online (Sandbox Code Playgroud)

如果我尝试运行我得到的程序,

Traceback (most recent call last):
  File "C:\Users\USER\Documents\Python Programs\World Population.py", line 13, in <module>
    body = soup.find("Born").findNext('p')
AttributeError: 'NoneType' object has no attribute 'findNext'
Run Code Online (Sandbox Code Playgroud)

这是python 3的问题还是我太天真了?

python beautifulsoup web-scraping

3
推荐指数
2
解决办法
3万
查看次数

标签 统计

beautifulsoup ×1

python ×1

web-scraping ×1