Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def eval(cmd, input=None):
return shuttle.eval(cmd['args'])
elif cmd['service'] == 'W': ## Weather
return weather.eval(input)
elif cmd['service'] == 'T': ## Transform
return transform.eval()
else:
return "ERROR 42: service not recognized"

Expand All @@ -33,6 +35,8 @@ def special(incoming):
body = laundry.special
elif incoming.upper() == "WEATHER":
body = weather.special
elif incoming.upper() == "TRANSFORM":
body = transform.special
elif incoming.upper() == "DEMO":
## welcome/instructions
body = 'Thanks for using Harvard Now!\n'
Expand Down
25 changes: 25 additions & 0 deletions services/transform/transform.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from bs4 import BeautifulSoup
import urllib2


def get_link_and_alt_text():
url = "https://www.instagram.com/deankhurana/"
page = urllib2.urlopen(url)
soup = BeautifulSoup(page.read(), 'html.parser')
data = soup.find(class_= '_8mlbc _vbtk2 _t5r8b')
link = data.get('href')
alt_text = data.find('img').get('alt')

return link + "\n" + alt_text

def makeSpecial():
s = "Here's the latest instagram post from Dean Khurana! \n"
s += get_link_and_alt_text()
return s

#toplevel

special = makeSpecial()

def eval():
return special