ここにPythonのnoobがあります。私はPythonでHTMLファイルに部分文字列を含む行を印刷しようとしています。私は文字列がファイル内にあることを知っています。なぜなら、文字列をCtrl + Fキーを押すと、htmlファイルで検索しているからです。しかし、私は私のコードを実行するときに、それは望ましい結果を印刷しません。誰かが私が間違っていることを説明することができますか?リクエストパッケージresponse.contentでHTMLファイルで文字列を検索していますか?
import requests
import datetime
from BeautifulSoup import BeautifulSoup
now =datetime.datetime.now()
cmonth = now.month
cday = now.day
cyear = now.year
find = 'boxscores/201'
url = 'http://www.basketball-reference.com/boxscores/index.cgi?lid=header_dateoutput&month={0}&day=17&year={2}'.format(cmonth,cday,cyear)
response = requests.get(url)
html = response.content
print html
for line in html:
if find in line:
print line