I would like to parse the HD price from the following snipper of HTML. I am only have fragments of the html code, so I cannot use an HTML parser for this.
BeautifulSoup is very lenient to the HTML it parses, you can use it for the chunks/parts of HTML too:
# -*- coding: utf-8 -*- from bs4 import BeautifulSoup data = u""" View In iTunes £19.99 HD Version """ soup = BeautifulSoup(data) print soup.find('span', class_='price').text[1:] Prints: 19.99 0 讨论(0) 查看其它5个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复
Prints:
19.99