1
我對使用python進行網頁編程非常陌生。目前,我正在努力從網站上「刮」一小部分信息。 網站:http://www.airport-data.com/airport/HJO/#location 信息提取/廢鋼:「海拔」(下位置見&自我簡介)從網頁上刮 - python
的代碼,我到目前爲止有:
from BeautifulSoup import BeautifulSoup
url2 = urllib2.urlopen('http://www.airport-data.com/airport/HJO/#location').read()
soup = BeautifulSoup(url2)
print soup #I did this just to see the content.
我試着在網上閱讀,看着以前的一些帖子但沒有把我的頭包裹起來。有關如何繼續從網絡鏈接中提取/提取「高程」的建議? 謝謝
謝謝爲ans WER。我做了'soup.find('td',class _ ='tc0',text ='Longitude/Latitude:')。next_sibling.text',它正在提取內容。但是''經度/緯度:'有兩條線'
'分開,我如何提取第二條線,即'
'後面的內容? (我可以通過字符串操作獲得第二行,但是想知道我是否可以在沒有字符串操作的情況下提取) – 2014-09-05 19:20:24
@SrinGupta當然,'print soup.find('td',text ='Longitude/Latitude:')。next_sibling.contents [2 ]'應該這樣做。 – alecxe 2014-09-05 19:29:59
太棒了!謝謝 – 2014-09-05 20:22:04