Last active
June 4, 2021 14:39
-
-
Save aritraroy24/2c1efcd0b040010345f1912d7a207f72 to your computer and use it in GitHub Desktop.
tweeting data after checking whether it is a repeat or not
This file contains hidden or 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 tweet(self, text_list, url_list): | |
''' | |
Posting the news in the twitter and logging the data (First news of the list will be posted: One can modify by using random function) | |
''' | |
# removing news already tweeted | |
file_name = "tweets.txt" | |
with open(file_name, "r") as file: | |
tweet_list = file.readlines() | |
tweet_list = [x.strip() for x in tweet_list] | |
for tweet in tweet_list: | |
for text, url in zip(text_list, url_list): | |
if text == tweet: | |
text_list.remove(text) | |
url_list.remove(url) | |
# tweeting the fast news from the modified newslist | |
for text in text_list: | |
i = 0 | |
try: | |
with open(file_name, "a") as file: | |
file.write(f"{text}\n\n") | |
api.update_status( | |
f"@aritraroy24 #compchem #news #update #science #chemistry #quantum\nπππΏπΌπ'π πππΏπΌππ: {text_list[i]}\n{url_list[i]}") | |
logger.info( | |
f"Tweet done at : {str(datetime.datetime.now())} === {text_list[i]} === {url_list[i]}\n\n\n") | |
i += 1 | |
break | |
except Exception as e: | |
logger.info( | |
f"Tweet can't be done at : {str(datetime.datetime.now())} due to {e} error\n\n\ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment