Lowercase and no-repeat message implemented
This commit is contained in:
parent
f05f45fe0c
commit
06ba187733
@ -38,11 +38,13 @@ def extract_binance(main_webpage, key_words):
|
|||||||
# Check for matchings
|
# Check for matchings
|
||||||
for article in list:
|
for article in list:
|
||||||
article_text = article.get_text().replace('\n', '')
|
article_text = article.get_text().replace('\n', '')
|
||||||
|
|
||||||
for item in key_words:
|
for item in key_words:
|
||||||
# If matching, create a new list
|
# If matching, create a new list. Use LOWERCASE!
|
||||||
if item in article_text:
|
if item in article_text.lower():
|
||||||
article_link = 'https://www.binance.com' + article.find('a').get('href')
|
article_link = 'https://www.binance.com' + article.find('a').get('href')
|
||||||
final_list.append([article_text, article_link])
|
final_list.append([article_text, article_link])
|
||||||
|
|
||||||
return final_list
|
return final_list
|
||||||
|
|
||||||
# Telegram function
|
# Telegram function
|
||||||
@ -51,10 +53,10 @@ def tg_call(update, context):
|
|||||||
update.message.reply_text("Hello mate! Let me start checking")
|
update.message.reply_text("Hello mate! Let me start checking")
|
||||||
|
|
||||||
# Create two empty list for storing and comparing urls
|
# Create two empty list for storing and comparing urls
|
||||||
old_urls, news_urls = [], []
|
old_urls, new_urls = [], []
|
||||||
|
|
||||||
# Create a bag of key words for getting matches
|
# Create a bag of key words for getting matches
|
||||||
key_words = ['List', 'list', 'Token Sale', 'Open Trading', 'open trading']
|
key_words = ['list', 'token sale', 'open trading', 'opens trading']
|
||||||
|
|
||||||
# Create the first pass
|
# Create the first pass
|
||||||
main_webpage = 'https://www.binance.com/en/support/categories/115000056351'
|
main_webpage = 'https://www.binance.com/en/support/categories/115000056351'
|
||||||
@ -64,17 +66,23 @@ def tg_call(update, context):
|
|||||||
while True:
|
while True:
|
||||||
# Get new list of urls
|
# Get new list of urls
|
||||||
new_urls = extract_binance(main_webpage, key_words)
|
new_urls = extract_binance(main_webpage, key_words)
|
||||||
|
|
||||||
for item in new_urls:
|
for item in new_urls:
|
||||||
# Compare if they were included in the former list
|
# Compare if they were included in the former list
|
||||||
if item not in old_urls:
|
if item not in old_urls:
|
||||||
msg = item[0] + '\n' + item[1]
|
msg = item[0] + '\n' + item[1]
|
||||||
api.update_status(msg) # Twitter
|
api.update_status(msg) # Twitter
|
||||||
update.message.reply_text(msg) # Telegram
|
update.message.reply_text(msg) # Telegram
|
||||||
|
|
||||||
|
# Append the message in order to not repeat the messages
|
||||||
|
old_urls.append(item)
|
||||||
|
|
||||||
update.message.reply_text('Done for now. Time to go to sleep mate!')
|
update.message.reply_text('Done for now. Time to go to sleep mate!')
|
||||||
time.sleep(900) # Sleep for 15 min
|
time.sleep(900) # Sleep for 15 min
|
||||||
|
|
||||||
# Main function
|
# Main function
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
# Create the updater
|
# Create the updater
|
||||||
updater = Updater(TG_TOKEN, use_context=True)
|
updater = Updater(TG_TOKEN, use_context=True)
|
||||||
|
|
||||||
@ -88,6 +96,6 @@ def main():
|
|||||||
updater.start_polling()
|
updater.start_polling()
|
||||||
updater.idle() # killall python3.7 to kill the app
|
updater.idle() # killall python3.7 to kill the app
|
||||||
|
|
||||||
# Start
|
# Start - Check if this file is run directly by python or it is imported
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
Loading…
x
Reference in New Issue
Block a user