我有这个跨度,我想用 Beautifulsoup 把 7 分钟搞定?
<span>In current traffic: 7 mins</span>
我试过了
res = soup.find('span')
title = res['In current traffic']
print 'Current Listeners:', title.text
但不起作用
*编辑
我的实际代码如下
from bs4 import BeautifulSoup
import urllib2
url = "https://maps.google.com.au/maps?saddr=A6&daddr=A6&hl=en&ll=-33.877613,151.039867&spn=0.081236,0.083599&sll=-33.869204,151.034546&sspn=0.081244,0.083599&geocode=FYSu-v0d2KMACQ%3BFbp0-_0dJKoACQ&mra=ls&t=m&z=14&layer=t"
content = urllib2.urlopen(url).read()
soup = BeautifulSoup(content)
res = soup.find('span')
title = res['In current traffic']
print 'Current Listeners:', res.text