只是想从一个网站上抓取事件的标题,我有他们的大部分,但它不会拿起一个标题。缺少的结果是:
AFL U16’s Championships
有人能告诉我需要在正则表达式中更改什么才能找到这个吗?你知道吗
from re import *
from urllib.request import urlopen
Website = 'https://thegabba.com.au/what-s-on.aspx'
print('Now Gathering Results from URL: ' + Website)
html_source = urlopen(Website).read().decode("UTF-8")
EventMatches = findall('<h6 class="event-title">([A-Za-z0-9\'\\s]+)</h6>',html_source)
print('There are ' + str(len(EventMatches)) + ' Events.')
for EventNames in EventMatches:
print(EventNames)
撇号
’
与单引号'
不同。如果你想把结果包括在内,你需要考虑到前者和后者。你知道吗内容实际上返回的是二进制而不是utf-8/ascii,因此被解码为iso-8895-1
我们在这里可能需要的表达是:
它捕获了
h6
标记中的所有内容。你知道吗DEMO
测试
正则表达式电路
jex.im可视化正则表达式:
相关问题 更多 >
编程相关推荐