0

reとのモジュールについて学んでいますBeautifulSoup。次のコードの数行に疑問があります。group()括弧の使い方と括弧の中身がわかりませんcontents[]

from bs4 import BeautifulSoup
import urllib2
import re

url = 'http://www.ebay.es/itm/LOTE-5-BOTES-CERVEZAARGUS-SET-5-BEER-CANSLOT-5-CANETTES-BIRES-LATTINE-BIRRA-/321162173293'  #raw_input('URL: ')   
code = urllib2.urlopen(url).read();
soup = BeautifulSoup(code)
tag = soup.find('span', id='v4-27').contents[0]

price_string = re.search('(\d+,\d+)', tag).group(1)
precio_final = float(price_string.replace(',' , '.'))

print precio_final
4

1 に答える 1