设为首页
收藏本站
开启辅助访问
切换到窄版
登录
立即注册
中问网首页
我的收藏
站长博客
搜索
搜索
本版
帖子
用户
第一问答网
»
论坛
›
中问网
›
问答
›
python萌新问题
返回列表
发新帖
python萌新问题
[复制链接]
11
|
4
|
2021-1-27 07:15:43
|
显示全部楼层
|
阅读模式
importrequests
frombs4importBeautifulSoup
res=requests.get('https://www.dxomark.com/category/smartphone-reviews')
html=res.text
soup=BeautifulSoup(html,'html.parser')
items=soup.find_all(class_='selectionWrapmobile')
foriteminitems:
deviceScore=item.find_all('class=deviceScore')
deviceName=item.find_all('h3')
foriindeviceScore:
print(i,end=('')
这个运行下来没有结果,没有报错。想问下哪里出问题了?
分 -->
回复
使用道具
举报
千问
|
2021-1-27 07:15:43
|
显示全部楼层
deviceScore=item.find_all('class=deviceScore')
这里写错了。导致没有匹配到内容。可修改为class_="deviceScore"
importrequests
frombs4importBeautifulSoup
res=requests.get('https://www.dxomark.com/category/smartphone-reviews')
html=res.text
soup=BeautifulSoup(html,'html.parser')
items=soup.find_all(class_='selectionWrapmobile')
foriteminitems:
deviceScore=item.find_all(class_="deviceScore")
deviceName=item.find_all('h3')
foriindeviceScore:
print(i,end=(''))
回复
使用道具
举报
千问
|
2021-1-27 07:15:43
|
显示全部楼层
不好意思啊但是改过之后还是错的
File"c:/Users/22531/OneDrive/桌面/Untitled-2.py",line8
deviceScore=item.find_all(class='deviceScore')
^
SyntaxError:invalidsyntax
回复
使用道具
举报
千问
|
2021-1-27 07:15:43
|
显示全部楼层
引用1楼--lx的回复:
deviceScore=item.find_all('class=deviceScore')
这里写错了。导致没有匹配到内容。可修改为class_="deviceScore"
importrequests
frombs4importBeautifulSoup
res=requests.get('https://www.dxomark.com/category/smartphone-reviews')
html=res.text
soup=BeautifulSoup(html,'html.parser')
items=soup.find_all(class_='selectionWrapmobile')
foriteminitems:
deviceScore=item.find_all(class_="deviceScore")
deviceName=item.find_all('h3')
foriindeviceScore:
print(i,end=(''))
不好意思还是错的
回复
使用道具
举报
千问
|
2021-1-27 07:15:43
|
显示全部楼层
引用1楼--lx的回复:
deviceScore=item.find_all('class=deviceScore')
这里写错了。导致没有匹配到内容。可修改为class_="deviceScore"
importrequests
frombs4importBeautifulSoup
res=requests.get('https://www.dxomark.com/category/smartphone-reviews')
html=res.text
soup=BeautifulSoup(html,'html.parser')
items=soup.find_all(class_='selectionWrapmobile')
foriteminitems:
deviceScore=item.find_all(class_="deviceScore")
deviceName=item.find_all('h3')
foriindeviceScore:
print(i,end=(''))
我重新试了一下,系统告诉我说unexpectedEOFwhileparsing
这是什么问题?
回复
使用道具
举报
返回列表
发新帖
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
本版积分规则
发表回复
回帖后跳转到最后一页
千问
主题
0
回帖
4882万
积分
论坛元老
论坛元老, 积分 48824836, 距离下一级还需 -38824837 积分
论坛元老, 积分 48824836, 距离下一级还需 -38824837 积分
积分
48824836
加好友
发消息
回复楼主
返回列表
问答
热门排行