Skip to content

Instantly share code, notes, and snippets.

@LordotU
Last active November 25, 2019 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LordotU/83b81f1459c5eec4ccc777538135955e to your computer and use it in GitHub Desktop.
Save LordotU/83b81f1459c5eec4ccc777538135955e to your computer and use it in GitHub Desktop.
TUI Flights Parser
def get_message(row, soup):
"""
Returns the Markdown formatted message
Args:
row (OrderedDict): A dictionary representation of urls.csv file row.
soup (BeautifulSoup): A Beautiful Soup web page representation.
Returns:
message (str): Markdown formatted message
"""
price_node = soup.find('span', class_='current-price')
if price_node is None:
return '*{0}*\n\n_Price was not found at:_\n\n{1}'.format(row['title'], row['url'])
price_value = price_node.get_text()
message = '*{0}*\n\n_{1}_'.format(row['title'], price_value)
return message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment