Skip to content

Instantly share code, notes, and snippets.

@staccDOTsol
Created October 3, 2020 13:06
Show Gist options
  • Save staccDOTsol/0b501387e1be3072baa83cb40a7bddc9 to your computer and use it in GitHub Desktop.
Save staccDOTsol/0b501387e1be3072baa83cb40a7bddc9 to your computer and use it in GitHub Desktop.
import requests
from xml.etree import ElementTree
m = requests.get('https://medium.com/feed/@jarettdunn').text
#print(m)
root = ElementTree.fromstring (m)
#root = ElementTree.fromstring(m)
strings = []
for node2 in root:
#print(node2.tag)
for node in node2:
#print(node.tag)
if node.tag == 'item':
#print(node)
s_name = node.attrib.get("name")
s_mail = node.find("title").text
s_grade = node.find("link").text
try:
s_age = node.findall("category")
string = "#"
for c in s_age:
string = string + (c.text) + " #"
string = string[:-2]
string = string + " " + s_mail
length = -1*(280 - 25)
string = string[length:]
string = string + " " + s_grade
strings.append(string)
except Exception as e:
print(e)
r = requests.get("https://www.random.org/integers/?num=1&min=0&max=" + str(len(strings)-1) + "&col=1&base=10&format=plain&rnd=new").text
r = int(r)
return({'link': strings[r]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment