https://github.com/captin411/ofxclient is a good place to start, if your bank supports it. Some banks (like Bank of America) charge you a monthly fee for OFX downloads. In those cases, you can write up a selenium script or something similar to login for you and scrape transactions once a day/week/whatever. That's obviously a fragile solution, however.
Quicken has the Web Connect bank connection option. I have a theory that this is similar to a selenium script where you can download a QFX file, but don't need 2FA to do it. Unfortunately, I haven't found any documentation on how this actually works, though.
I also use the referenced ofxclient which is analogous to Quicken's Direct Connect. BofA is inconsistent with applying fees for using Direct Connect.