I have a list structure like this:
listpost =
[
{
"post_id":"01",
"text":"abc",
"time": datetime.datetime(2021, 8, 5, 15, 53, 19),
"type":"normal",
},
{
"post_id":"02",
"text":"nothing",
"time":datetime.datetime(2021, 8, 5, 15, 53, 19),
"type":"normal",
}
]
I want to filter the list by text in [text] key if only the [text] has "abc"
so the example will look like this
listpost =
[
{
"post_id":"01",
"text":"abc",
"time": datetime.datetime(2021, 8, 5, 15, 53, 19),
"type":"normal",
}
]
My code:
from facebook_scraper import get_posts
listposts = []
for post in get_posts("myhealthkkm", pages=1):
listposts.append(post)
print(listposts)
ifstatement to only appendpostifpost['text']is equal to'abc'?