0
resp = urlopen('http://international.o2.co.uk/internationaltariffs
/getintlcallcosts?countryId=IND').read()
crawler = bs4.BeautifulSoup(resp, 'html.parser')
div = crawler.find('div', {"id": "standardRates"})
div
Webscraping與BeautifulSoup在Python
與上面的代碼它列出了所有的標籤/元素,你可以在圖片中看到。我想獲得「2.00英鎊」。除了當我再次調用.find(「TD」)如下:
div = crawler.find('div', {"id": "standardRates"}).find('td')
它只返回座機,而不是線下,即使它具有相同的標籤。我在網絡抓取方面的經驗很少。我如何定位這個標籤(2.00英鎊的行)?
嘗試'的findAll()',而不是僅僅找'()'' – MooingRawr
.findAll( 'TD')[1]'要準確 –
大奏效。雖然結果是一個列表,所以當我使用.contents時,字符串被方括號包圍。我可以得到它,所以它只是一個字符串? – Paulos