Repository to store an application using Python to web scrapping news/articles from sites, transform in an epub format and send via email to a Kindle for reading.
Source: Photo by Obi - @pixel7propix on Unsplash
Firstly, we need to clone this repository
$ git clone https://github.com/BrenoAV/articles-to-kindle.git && cd news-to-kindle/
- Go to https://console.cloud.google.com/apis/dashboard and create a new project
- Now, we need to enable the Google Gmail API. Search for Gmail API and turn on
- After to enable, we can create now our credentials using Oauth 2.0. For that, click on
Credentials
→Create Credentials
→OAuth client ID
- To create an OAuth client ID, you must first configure your consent screen. Click on create, select
external
, fill the mandatory forms:App Name
,User support email
, andDeveloper contact information
- Return to the Credentials tab and create now the OAuth client ID, and select Desktop application.
Type a name for your OAuth client and click on create button.
- Click on
download json
and save it with the namecredentials.json
-
You need to have your Kindle email. This is a tutorial if you don't know your email: https://www.lifewire.com/find-kindle-email-address-5271915. Remember that you need to allow your email to send for your Kindle → Add an Email Address to Receive Documents in Your Kindle Library
-
Create a
.env
file with the following content, where your have to put yours emails in the fields:
# .env file
OUR_EMAIL = "youremail@gmail.com"
KINDLE_EMAIL = "yourkindleemail@kindle.com"
- We need to install python's necessary dependencies:
$ pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib pypandoc beautifulsoup4 PyYAML python-dotenv
-
We need to have pandoc installed in our system. This is a tutorial if you don't have yet: https://pandoc.org/installing.html
-
I ran this in a python environment using Debian Testing and python==3.11.2
- After all the setup part you can now run:
$ python main.py
and will open the GUI of the program
-
Type link of the articles that you want to send for you kindle from https://www.bbc.com/future/ . I'll take this article here: https://www.bbc.com/future/article/20230405-why-ai-is-becoming-impossible-for-humans-to-understand
- For now, just work with the BBC Future (it's a good site to read and practice English reading skills)
- It's allow getting from this endpoint as you can see on https://www.bbc.com/robots.txt
-
Click on the button
Send article to Kindle
, and it'll prompt a window on your browser to authenticate. Click on the buttonContinue
- This process when succeeded returns a response in the browser with the following text: "The authentication flow has completed. You may close this window."
- You'll receive the article in epub format in your Kindle. For me:
- Document the code (functions)
- Add others sources of obtain news or articles
- Improve the GUI with some errors if you put some invalid option or if the authenticate process fails
- Add in the GUI to insert the emails instead of create a .env file