I need to do some filtering and cleaning to get rid of unwanted data. In the end, I store the data in a dict with fields as key and statuses as value. I read the corresponding style for each football field and checked whether the background color was RED (unplayable) or GREEN (playable). Since the football fields information is inside span tags, I use the find_all("span") function to find them all. So… I decided to go with BeautifulSoup, which is a Python library for pulling data out of HTML. My first idea was to parse the HTML using some Regex, but my colleague showed me this awesome answer on Stackoverflow. The only option is to write some logic that collects the wanted data from the HTML page itself. There is no available API for the data I want my bot to tweet out. Getting the data for the Tweetįinally, I can go ahead with the fun stuff. I also create an empty requirements.txt file since I know that we will use external dependencies. The last thing I need to set up is an AWS account, which I did here.Īs always, when I develop using Python, I prefer working in virtual environments.The needed API Keys and API Tokens is then available under the Keys and Token Tab. On the App overview, I made sure to set the correct permissions.I need to create a Project in the Twitter Developer Portal and then create an App inside the Project.I link the Developer Account with my Twitter account to gain access to the API keys and secrets. It is possible to apply for access here here. Once I have a Twitter account, I need to create a Twitter Developer Account. First, I need a Twitter account for the bot, create one here.Prerequisiteīefore I start, there are a few prerequisites to set up. The Twitter bot will be developed in Python and deployed as a Lambda function in AWS. My Twitter bot will fetch data from this page and tweet a list of the unplayable fields three times a day. One has to go to that webpage to check if the field of interest is playable or not. Currently, there is a webpage that gets updated daily with the statuses of the fields. When it rains too much, commonly, some football fields around the city become unplayable. I live in Gothenburg and this city is known as “Little London” because of how often it rains here. But last week, I found a perfect use case for my Twitter bot. I’ve wanted to try out Twitter’s API and create a Twitter bot for a while, but I lacked a use case for it. Creating a Twitter bot in Python and let it move into AWS.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |