Mike Stone on Nostr: I'm a garbage #Python programmer, and even I can pull this off. import requests, ...
I'm a garbage #Python programmer, and even I can pull this off.
import requests, json, re
def strip_html(text):
pattern = re.compile(r"<.*?>", re.DOTALL)
return pattern.sub("", text)
i = "
https://fosstodon.org/api/v1/timelines/public";
m = requests.get(i)
d = json.loads(m.content)
for x in d:
dat = x["account"]
txt = x["content"]
print (dat["display_name"] + " (" + dat["acct"] + "):")
print (strip_html(txt))
print("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-")
Published at
2023-08-01 15:58:49Event JSON
{
"id": "8894ec412fcd3157905bbcdd2f7b9024aec58af02051f8a5c7f6e2440620481d",
"pubkey": "fc716aae6ef40aa3e0ebb6ad8165d2bcb786bff9827d29e21115db5730c493e0",
"created_at": 1690905529,
"kind": 1,
"tags": [
[
"t",
"python"
],
[
"proxy",
"https://fosstodon.org/users/mike/statuses/110815184768969001",
"activitypub"
]
],
"content": "I'm a garbage #Python programmer, and even I can pull this off. \n\nimport requests, json, re\n\ndef strip_html(text):\n pattern = re.compile(r\"\u003c.*?\u003e\", re.DOTALL)\n return pattern.sub(\"\", text)\n\ni = \"https://fosstodon.org/api/v1/timelines/public\"\nm = requests.get(i)\nd = json.loads(m.content)\n\nfor x in d:\n dat = x[\"account\"]\n txt = x[\"content\"]\n print (dat[\"display_name\"] + \" (\" + dat[\"acct\"] + \"):\")\n print (strip_html(txt))\n print(\"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\")",
"sig": "3926159522248de484f83bd46515b1cbe6a5a241cb9e920c0dbf317b88a6d4d2bb1ce735f7bc1bb1a3652637c7df728ef12db22d33e7a6f2f15456c47c0e3955"
}