Python 使用selenium的facebook群组帖子抓取为所有帖子提供了相同的作者名称

Python 使用selenium的facebook群组帖子抓取为所有帖子提供了相同的作者名称,python,selenium,Python,Selenium,我正在使用selenium在python中抓取facebook组数据。我正在使用以下代码获取数据: posts = self.browser.find_elements_by_class_name("userContentWrapper") for count, post in enumerate(posts): analysis = [posts[count].find_element_by_xpath("//a[@data-hovercard-referer]").text]

我正在使用selenium在python中抓取facebook组数据。我正在使用以下代码获取数据:

posts = self.browser.find_elements_by_class_name("userContentWrapper")

for count, post in enumerate(posts): 
    analysis = [posts[count].find_element_by_xpath("//a[@data-hovercard-referer]").text]
    text = post.find_element_by_class_name("userContent").text
    status = self.strip(text)
    analysis.append(status)


上面的代码为我提供了一个facebook群组所有帖子的作者姓名。如何更改程序以显示正确的作者姓名

你的页面上的HTML是什么/指向你正在自动化的页面的链接是什么?如果没有这些,很难帮上忙。给我们看一些html示例。不要指望我们去facebook(呃)找到它ourselves@KentKostelac跳到你说的上来——Facebook很可能已经采取了措施来防止UI自动化准确地刮取他们的页面。我见过几个Facebook的例子,它们通过强制页面HTML中存在不一致性和延迟加载Javascript函数,使得尽可能难以抓取页面内容。这可能不是实现自动化的最佳网站。