can python do this?

Lie Ryan lie.1296 at gmail.com
Thu Dec 3 21:54:34 EST 2009


On 12/3/2009 4:55 AM, Anssi Saari wrote:
> Rounak<irounakjain at gmail.com>  writes:
>
>> I am a complete newbie. I want to know if the following can be done
>> using python or should I learn some other language:
>> (Basically, these are applescripts that I wrote while I used Mac OS)
>> 1.Web Page Image to Wallpaper:
>> A script that takes the current image in a browser and sets it as a
>> wallpaper.
>> http://forums.obdev.at/viewtopic.php?f=24&t=3462
>
> I don't know if any Linux web browsers are particularly scriptable.
> Firefox at least is pretty much limited to opening URLs and some other
> windows. OTOH, you can do that specific thing by just right clicking
> on the image in question and selecting set as desktop background...

Nope, you don't need to, you just need to find a way to pass the URL to 
your script and python can do the rest with urllib. Most browsers 
doesn't have functionality to pass url to an outside program, but with 
firefox you can be able to write an addon that do that (or perhaps onne 
is already available?).

>> 2.Screenshot with name, format, Dropbox upload and public URL
>> I used to run this script,type the name for screenshot and press return.
>> The screenshot would be uploaded to Dropbox and public url would be
>> copied to clipboard.
>> http://forums.obdev.at/viewtopic.php?f=24&t=3448

If you're on linux, you can use ImageMagick's "import" or "scrot" with 
subprocess module to take screenshots. PIL (Python Imaging Library) can 
also do that more cleanly. Most windowing systems (GTK/Qt) also have 
their own ways 
(http://stackoverflow.com/questions/69645/take-a-screenshot-via-a-python-script-linux).

You can use urllib and/or httplib to communicate with Dropbox. You just 
need to find the URLs to send HTTP POST to, and parse the resulting 
webpage to extract the public URL. (perhaps do some login as well, I 
don't know never used Dropbox)



More information about the Python-list mailing list