Scraping and automating things on twitter are not allowed according to their TOS. There is a good chance that your account gets banned! Seriously, only use this tool if you're okay with loosing your account!
Twitter has been ramping up the amount of promoted tweets in my timeline recently. I don't like ads, most of the time they are not relevant. I hate when people pay money to try to get my attention - I started blocking them, manually.
This has been fun for a while and oddly comforting whenever I hit that block button. After a while I got addicted, now I need more blocking, mooooaaaaarrrrr! No, I'm not a cheap guy - I would happily pay for twitter pro without ads... if there ever was such a thing.
- use selenium to drive a browser ✓
- log in to twitter account ✓
- scrape timeline ✓
- find any tweet marked with "promoted" ✓
- block the account that promoted the tweet by clicking more > block @user > confirm ✓
[☩] Loading Target: https://twitter.com/login
[☑] Logged In As User: XXX
-------------------------------
[⚠] Promoted Tweet Found!
[⊘] Blocking User: YYY
[☭] Blocked 1/10 Promoters
===============================
[⚠] Promoted Tweet Found!
[⊘] Blocking User: ZZZ
[☭] Blocked 2/10 Promoters
===============================
.
.
.
It does. Twitter seems to deliver less promoted content on web-browsers than in the native app so finding promoted tweets and blocking their source with this tool takes quite a while but it steadily grew my list of blocked accounts. As the list got longer and longer I now have to scroll quite a while on my phone to find any promoted tweets :)
- install Firefox & geckodriver
- set up python and dependencies (you can use anaconda and the environment file included)
- add your twitter handle and password to the secrets file
- let her rip
python -m twitter_problock
For more output:
python -m twitter_problock -v
-
using the twitter API to retrieve the timeline as the response does not contain promoted tweets
-
use the twitter API to add promoting accounts to the block list - you have to apply for an API key, even if I get one... other ppl using problock might not be so lucky. API keys could also be revoked...
-
not using selenium but mechanicalsoup or something else
<h1>JavaScript is not available.</h1>
<p>We’ve detected that JavaScript is disabled in this browser. Please enable JavaScript or switch to a supported browser to continue using twitter.com. You can see a list of supported browsers in our Help Center.</p>