你好澳洲朋友:)
如果我是你,我會使用請求和lxml。我認爲該網站正在檢查cookie和一些標題。請求會話類存儲cookie,並且可以讓你傳遞標題。 lxml會讓你在這裏使用xpath,我認爲它比BeautifulSoup的界面更不痛苦。
見下文:
>>> import lxml.html
>>> import requests
>>> session = requests.session()
>>> response = session.get("http://www.footywire.com/afl/footy/ft_match_statistics?mid=5634", headers={"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Referer":"http://www.footywire.com/afl/footy/ft_match_statistics?mid=5634","Cache-Control":"max-age=0"})
>>> tree = lxml.html.fromstring(response.text)
>>> rows = tree.xpath("//table//table//table//table//table//table//tr")
>>> for row in rows:
... row.xpath(".//td//text()")
...
[u'\xa0\xa0', 'Sydney Match Statistics (Sorted by Disposals)', 'Coach: ', 'John Longmire', u'\xa0\xa0']
['Player', 'K', 'HB', 'D', 'M', 'G', 'B', 'T', 'HO', 'I50', 'FF', 'FA', 'DT', 'SC']
['Josh Kennedy', '20', '17', '37', '2', '1', '1', '1', '0', '3', '1', '0', '112', '126']
['Jarrad McVeigh', '23', '11', '34', '1', '0', '0', '2', '0', '5', '1', '1', '100', '116']
... cont...
XPath查詢可能有點脆,但你的想法:)