-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
28 lines (23 loc) · 935 Bytes
/
Copy pathmain.py
File metadata and controls
28 lines (23 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
from TwitterBot import TwitterBot
from bs4 import BeautifulSoup
import requests
CHROME_DRIVER_PATH = '/Users/jesseturner/Desktop/Development/chromedriver114/chromedriver'
TWITTER_EMAIL = os.environ.get("TWITTER_EMAIL")
TWITTER_PASSWORD = os.environ.get("TWITTER_PASSWORD")
print(TWITTER_PASSWORD)
print(TWITTER_EMAIL)
WORD_OF_THE_DAY_WEBSITE = 'https://www.merriam-webster.com/word-of-the-day'
twit = TwitterBot(TWITTER_EMAIL, TWITTER_PASSWORD, CHROME_DRIVER_PATH)
# -------------GET THE WORD OF THE DAY---------#
response = requests.get(url=WORD_OF_THE_DAY_WEBSITE)
soup = BeautifulSoup(response.text, features='html.parser')
word = soup.find('h2').text
word = word.upper()
definition = soup.find('p').text
if len(definition) > 240:
split_def = definition.split('.')
definition = split_def[0]
post_text = f" - {word} - \n {definition}"
# ----------------MAKE POST--------------------#
twit.make_post(post_text)