为了账号安全,请及时绑定邮箱和手机立即绑定

通过beautifulsoup和re提取数据

通过beautifulsoup和re提取数据

www说 2021-03-07 16:13:31
我正试图从jb hifi中提取特殊信息,这是我所做的:from BeautifulSoup import BeautifulSoupimport urllib2import reurl="http://www.jbhifionline.com.au/support.aspx?post=1&results=10&source=all&bnSearch=Go!&q=ipod&submit=Go"page=urllib2.urlopen(url)soup = BeautifulSoup(page.read())Item0=soup.findAll('td',{'class':'check_title'})[0]    print (Item0.renderContents())输出为:Apple iPod Classic 160GB (Black) <span class="SKU">MC297ZP/A</span>我想要的是:Apple iPod Classic 160GB (Black)我尝试使用re删除其他信息 print(Item0.renderContents()).replace{^<span:,""} 但这没用所以我的问题是如何删除无用的信息并获得“ Apple ipod classic 160GB(黑色)”
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 250 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号