擅长:python、mysql、java
<p>内容实际上返回的是二进制而不是utf-8/ascii,因此被解码为iso-8895-1</p>
<pre><code>#!/usr/bin/python3
import re
import requests
Website = 'https://thegabba.com.au/what-s-on.aspx'
print('Now Gathering Results from URL: {}'.format(Website))
html_source = requests.get(Website).content.decode('ISO-8859-1')
EventMatches = re.findall(r'<h6 class="event-title">([A-Za-z0-9\'\s]+)<\/h6>', html_source)
print('There are {} Events.'.format(len(EventMatches)))
for EventNames in EventMatches:
print(EventNames)
</code></pre>
<pre><code>Now Gathering Results from URL: https://thegabba.com.au/what-s-on.aspx
There are 14 Events.
Brisbane Lions v Hawthorn Football Club
Brisbane Lions v Melbourne Football Club
Brisbane Lions v North Melbourne Football Club
Stadium Stomp
Brisbane Lions v Western Bulldogs
Brisbane Lions v Gold Coast Suns
Muscle Up For MND
Brisbane Lions v Geelong Football Club
Australia v Sri Lanka
Australia v Pakistan
Pakistan v New Zealand
Australia v A1
New Zealand v A1
England v Afghanistan
</code></pre>