我已经尝试了一段时间,现在成功地通过博彩网站分析和检索市场/赔率。你知道吗
我已经到了获取Selenium web元素的.text属性的时候了,所以我有这样的东西:
编辑以展示更多示例
BPZ vs Griffin - League of Legends - Challenger Korea
Sat 2/25 1511 BPZ 1.645
10:30PM 1512 Griffin 2.250
Team Battle Comics vs RisingStar Gaming - League of Legends - Challenger Korea
Sat 2/25 1513 Team Battle Comics 5.800
11:59PM 1514 RisingStar Gaming 1.133
Going In vs Hala Ares - Dota 2 - Prodota Cup
Sat 2/25 1529 Going In 1.667
1:30PM 1530 Hala Ares 2.200
Unicorns of Love vs G2 Esports - League of Legends - Intel Extreme Masters
Sat 2/25 1545 Unicorns of Love 2.750
11:15AM 1546 G2 Esports 1.444
在谷歌搜索了几个小时正则表达式并阅读了语法之后,我不能做的是根据需要提取这个字符串的部分。在上面的字符串中,如果我可以使用regex将其过滤到如下所示的字典中:
{'event':'BPZ vs Griffin - League of Legends',
'outcome1':'BPZ',
'outcome2':'Griffin',
'outcome1odds':1.645,
'outcome2odds':2.25,
'date':'Sat 2/25',
'time':'10:30PM'}
那我就非常高兴了。我相当肯定这是可能的,但是我有太多的困难,我的头围绕regex实现它。非常感谢您的帮助和/或资源。你知道吗
这种模式应该起到以下作用:
它很长,但作为交换,您可以使用
.groupdict()
函数直接获得所需的结果:分解:
使用这个长正则表达式,您可以在8个组中找到数据:
https://regex101.com/r/2IdfnB/2
使用re.match()和match.groupdict()(获取匹配的所有命名子组)方法的解决方案:
输出:
相关问题 更多 >
编程相关推荐