Skip to content

Commit

Permalink
updating this repo to mirror the private repo - changes made to how t…
Browse files Browse the repository at this point in the history
…he tweet length is controlled and maximised, plus tweet thread numbering and a final tweet with pdf link
  • Loading branch information
jdm79 committed Dec 24, 2020
2 parents aea6a2c + 70a7465 commit 4d98e84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
## Python web scraper Twitter bot

This script scrapes the [House of Lords Hansard website](https://hansard.parliament.uk/lords/) every day at 6pm and tweets the issues debated that day (if they are debating - which they don't usually do on Fri, Sat and Sun).
This script scrapes the [House of Lords Hansard website](https://hansard.parliament.uk/lords/) every day at 6pm and tweets the issues debated that day (if they are debating - which they don't usually do on Fri, Sat and Sun).

It runs on a free Heroku account using the Heroku Scheduler add-on. I wrote this script originally in Ruby and ran it on my local machine on a 24-hour loop.
This is not the github repo for the Twitter bot now that it's on Heroku as I don't want to have my API tokens and oauth in public. Currently I keep the tokens and oauth stuff all in the same main file now, as the config wasn't working on Heroku. Whenever I update the private repo, I try to keep this repo similar.

In the other repo I have another script similar to this which runs at 10pm as the final round-up - it is usually different too as they seem to never stop updating these lists.

It runs on a free Heroku account using the Heroku Scheduler add-on for both scripts. I wrote this script originally in Ruby and ran it on my local machine on a 24-hour loop.

I've put this up here as much for my future self, to remind me how this all works and to use as a template.

You can visit me on Twitter [here](https://twitter.com/HansardLord).
You can visit this bot on Twitter [here](https://twitter.com/HansardLord).

### Features

Expand Down Expand Up @@ -35,4 +39,3 @@ or:

If you're scraping a different website, you'll have to use inspect element on the html page to find the elements you want and change the code accordingly.

ALWAYS PUT YOUR CONFIG.PY IN .GITIGNORE, else people will see your secret tokens and keys and take over your bots!
1 change: 1 addition & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)


days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
today = date.today().isoweekday() - 1
day = days[today]
Expand Down

0 comments on commit 4d98e84

Please sign in to comment.