AttributeError:“非类型”对象在python中没有属性“组”(问题)

2024-10-04 11:31:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码有问题

pageNameOrId = 'Ch3Thailand'
source_url = 'https://www.facebook.com/pg/%s/posts/' % pageNameOrId
content = html.unescape(requests.get(source_url).text)
postInfos = getPostInfosFromContent(content)
posts = getPostsFromContent(content, postInfos)
urlResult = re.search(r'\/pages_reaction_units.*?unit_count=8', content).group()
print(len(posts), posts[-1])

然后得到这样的错误

AttributeError                            Traceback (most recent call last)
<ipython-input-29-69969f51fdc6> in <module>()
----> 6 urlResult = re.search(r'\/pages_reaction_units.*?unit_count=8', content).group()

AttributeError: 'NoneType' object has no attribute 'group'

Tags: reurlsourcesearchcountgroupunitpages