I got the message by hitting the API, but I want to get at least
--User ID
Of these, I couldn't get the user ID, so I tried trial and error. The story described here is originally located on GitHub.
Even if you do some kind of analysis material, it seems that you can not talk without at least the following three pieces of information.
The requirement this time is to extract these three pieces of information from all posts (of a specific channel).
As a result of trial and error, I concluded that the following feelings would be good.
For time and text,
data = json.load(open("posts.json"))
for msg in data:
print msg.get("ts", "")
print msg.get("text", "")
It's OK with a feeling like.
Regarding user acquisition, those that cannot be acquired under the following conditions are through.
def get_user_id(m):
if m.has_key("user"): return m["user"]
if m.has_key("bot_id"): return m["bot_id"]
return None
for msg in data:
uid = get_user_id(msg)
if uid is None:
continue
# do something ...
Under the verification conditions, the number of posts corresponding to this was 0.2 [%] of the total, so we conclude that it can be ignored.
Data comes from your company's random channel. I will refrain from disclosing the specific period and the number of posts, but I looked at the messages posted in a period of about one and a half years.
that's all.
Recommended Posts