我希望看到字符串的正常输出
# -*- coding: utf-8 -*-
from bs4 import BeautifulSoup
import requests
url = 'http://new.cpc.com.tw/division/mb/oil-more1-1.aspx'
html = requests.get(url).text
sp = BeautifulSoup(html,"html.parser")
data = sp.find_all('span',{'id':'Showtd'})
rows = data[0].find_all('tr')
prices = list()
for row in rows:
cols = row.find_all('td')
if len(cols[1].text) > 0:
item = [s[0].text,cols[1].text,cols[2].text,cols[3].text,]
prices.append(item)
for p in prices:
print p
其输出:
[u'113F 1209800',u'98 \ u7121 \ u925b \ u6c7d \ u6cb9',u'\ u6563 \ u88dd',u'\ u4e00 \ u822c \ u81ea \ u7528 \ u5ba2 \ u6236']
我的预期输出:
[2016/01/18',18.4',19.9,21.9']
我该如何解决?