我正在尝试通过解析 html 编译以下代码,但出现错误:
import string, urllib2, urlparse, csv, sys
from urllib import quote
from urlparse import urljoin
from bs4 import BeautifulSoup
from ast import literal_eval
changable_url = 'http://www.asusparts.eu/partfinder/Asus/All%20In%20One/E%20Series'
page = urllib2.urlopen(changable_url)
base_url = 'http://www.asusparts.eu'
soup = BeautifulSoup(page)
selects = []
redirects = []
model_info = []
#Opening csv writer
c = csv.writer(open(r"asus_stock.csv", "wb"))
#Object reader
cr = csv.reader(open(r"asus_stock.csv", "rb"))
print "FETCHING OPTIONS"
select = soup.find(id='myselectListModel')
selects.append(select)
print selects.get_text()
错误是:
print selects.get_text()
AttributeError: 'list' object has no attribute 'get_text'
我怎么能通过这个错误?谢谢。