2016-08-10 3 views
0

웹 사이트에서 특수 ID가있는 번호를 가져 오는 BeautifulSoup을 사용하려고합니다. 이건 내 코드입니다웹 스크래핑 AttributeError

from urllib2 import urlopen 
from bs4 import BeautifulSoup 
import requests, logging 
logging.basicConfig() 
html = urlopen("http://example.com") 
bsObj = BeautifulSoup(str(html), "html.parser") 
select = bsObj.findAll(id="myid") 
print(select.get_text()) 

하지만 'AttributeError :'ResultSet '객체에'get_text '속성이 없습니다. 어디에 문제가 있습니까?

답변

2

ResultSet은 목록과 비슷하기 때문에 select[0].get_text() 또는 뭔가해야 할 것입니다.

여기

더 : Beautiful Soup: 'ResultSet' object has no attribute 'find_all'?

+0

그리고 그것은 단지 IndexError 결과 : 목록 인덱스 범위를 벗어났습니다. 어떻게 지금 디버깅 할 수 있습니까? – amin

+0

http://stackoverflow.com/questions/37335219/empty-result-set-beautiful-soup – user357269