DEV Community

Fernando Tricas García
Fernando Tricas García

Posted on

Amazon, please, allow me to send documents to my kindle

I'm a happy user of the feature of Kindles that allows sending documents via email. The device has a 'secret' address and if you send your document there, the document appears 'automagically' in your device. So far so good.

Last week I started to receive messages from Amazon Kindle Support asking me for some more work:

Alt Text

That is, you need to click on some link and then Amazon delivers the document. For a heavy user like me (around 10 documents daily) it is too much work.

I have seen some references in the web Amazon emailing me to verify every book I sent to kindle now
and the links provided by Amazon are not really useful.

What to do?
Well, we can process the 'automagically' generated messages with a program, look for the link inside each one of them and then, doing the actual click.

For this, once you have the body of the message (I'm reading a GMail account with my moduleGmail but any account and any way of reading them is ok), you can do a quick and dirty search:

message = api.getMessageId(idPost)
pos = message.find('https://www.amazon.com/gp')
# We are looking for the second one; the first 
# one is the image used in the mail for showing 
# the link.
pos = message.find('https://www.amazon.com/gp', pos + 1)
pos2 = message.find('"', pos+1)
if pos >= 0:
    url = message[pos:pos2]
    import requests
    # The actual click is here:
    response = requests.get(url)
Enter fullscreen mode Exit fullscreen mode

Then, we can delete the message, if we want. My robot against Amazon robots. Let's see.

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay