Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行两次之后发生了“find_all”返回空值的错误 #2

Open
YuMXuan opened this issue Jan 7, 2018 · 7 comments
Open

运行两次之后发生了“find_all”返回空值的错误 #2

YuMXuan opened this issue Jan 7, 2018 · 7 comments

Comments

@YuMXuan
Copy link

YuMXuan commented Jan 7, 2018

Traceback (most recent call last): File "hero.py", line 56, in <module> results = baiduSearch.search(keyword) File "D:\MillionHeroes-master\baiduSearch\search.py", line 8, in search results = process.page(page) File "D:\MillionHeroes-master\baiduSearch\process.py", line 46, in page result_set = result_set.find_all('div', class_='c-container') # 结果class固定,其余为硬广 AttributeError: 'NoneType' object has no attribute 'find_all'

一开始运行正常,尝试几次之后突然出现错误。

@wuditken
Copy link
Owner

wuditken commented Jan 7, 2018

我这边没问题
你看是不是汉王识别的次数用完了。你可以用自己的

@YuMXuan
Copy link
Author

YuMXuan commented Jan 7, 2018

汉王次数没有用完,问题识别没有问题,就是答案出不来了
主要是没动代码突然出的问题,头疼

@wuditken
Copy link
Owner

wuditken commented Jan 7, 2018

你换一个识别图片看看

@wuditken
Copy link
Owner

wuditken commented Jan 7, 2018

我也出现这问题,应该是要识别的图片不对,没有文字就报这个错误
Traceback (most recent call last):
File "hero.py", line 56, in
results = baiduSearch.search(keyword)
File "C:\Users\Administrator\Pictures\baiduSearch\search.py", line 8, in search
results = process.page(page)
File "C:\Users\Administrator\Pictures\baiduSearch\process.py", line 46, in page
result_set = result_set.find_all('div', class_='c-container') # 结果class固定,其余为硬广
AttributeError: 'NoneType' object has no attribute 'find_all'

C:\Users\Administrator\Pictures>python hero.py

@YuMXuan
Copy link
Author

YuMXuan commented Jan 7, 2018

统一更改了一下图片路径,运行了一下
图片的截图看了一下是对的
识别出来的问题的文字是对的
问题可能出在搜索的那个部分
search.py 和 process.py的results可能有点问题,貌似没有返回值

@wuditken
Copy link
Owner

wuditken commented Jan 8, 2018

还没解决吗?你可以试试运行下面的代码,看看搜索出来没
`import baiduSearch

keyword = '标志是雪山和雄狮的好莱坞电影公司分别是?'

convey = 'n'

if convey == 'y' or convey == 'Y':
results = baiduSearch.search(keyword, convey=True)
elif convey == 'n' or convey == 'N' or not convey:
results = baiduSearch.search(keyword)
else:
print('输入错误')
exit(0)
count = 0
for result in results:
#print('{0} {1} {2} {3} {4}'.format(result.index, result.title, result.abstract, result.show_url, result.url)) # 此处应有格式化输出
print('{0}'.format(result.abstract)) # 此处应有格式化输出
count=count+1
if(count == 2):
break`

@YuMXuan
Copy link
Author

YuMXuan commented Jan 8, 2018

刚刚试了一下,有些题目能搜索出来,有些不行,难道是广告??
我下一次换bing搜索试试

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants