使用 Beautiful soup 抓取特定用户的论坛帖子

Scrape Forum posts from a specific user using Beautiful soup

我是一个完整的 python 新手,对于我的第一个项目,我尝试使用 python 脚本从论坛线程中抓取特定用户的帖子,然后将其粘贴到原始文件。

我正在使用 python 编码语言和漂亮的 soup 编码库,但是在针对线程上的特定用户进行过滤时遇到了障碍,

我应该如何过滤我的脚本以仅保存特定用户在 python 中的帖子? 这是我将从中删除的论坛

https://forums.spacebattles.com/threads/the-wizard-of-woah-and-irrational-methods-of-irrationality.337233/

use Xpath like this to get the user name posted in the forum

from bs4 import BeautifulSoup 
import requests 
page = requests.get('https://forums.spacebattles.com/threads/the-wizard-of-woah-and-irrational-methods-of-irrationality.337233/page-2')
page_source = page.content
soup = BeautifulSoup(page_source)
post = soup.body.find('div', 'messageContent')
user_name = post.find('div', 'attribution type')
if 'Harry Leferts' in user_name:
    '''save the post '''

I have done to get single post from the forum, you can get all post by using find_all