Last active
November 25, 2019 21:28
-
-
Save LordotU/83b81f1459c5eec4ccc777538135955e to your computer and use it in GitHub Desktop.
TUI Flights Parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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