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.

Top comments (0)