0
웹 사이트에서 표를 긁어 내려고했습니다. 실행되지만 내 파일로 출력되지 않습니다. 내가 어디로 잘못 가고 있니?웹 스크래퍼 코드 (python3.4)의 문제점
코드 :
from bs4 import BeautifulSoup
import urllib.request
f = open('nbapro.txt','w')
errorFile = open('nbaerror.txt','w')
page = urllib.request.urlopen('http://www.numberfire.com/nba/fantasy/full-fantasy-basketball-projections')
content = page.read()
soup = BeautifulSoup(content)
tableStats = soup.find('table', {'class': 'data-table xsmall'})
for row in tableStats.findAll('tr')[2:]:
col = row.findAll('td')
try:
name = col[0].a.string.strip()
f.write(name+'\n')
except Exception as e:
errorFile.write (str(e) + '******'+ str(col) + '\n')
pass
f.close
errorFile.close
위대한 사람 감사합니다 ... 이제 작동하고 있습니다. –
이제이 코드를 연구하고 이해해야합니다. –