#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Questioner's home
    Posts
    89
    Rep Power
    12

    Getting image files from websites, izzit possible?


    Ok, Im a big fan of DeviantArt artists, I am "watching" a list of artists, and if any of them submitted a new piece of art, my account will inform me of their pics.

    Now I'm pretty busy, and I dont have time to browse through hundreds of pics and download each of them. So Im gonna write myself a tiny program to retrieve files from DeviantArt, based on my "watch" list.

    But I'm not sure if I'm able to do that, so I'm gonna tell you guys my concept and can you please tell me if my idea works or perhaps gimme better ideas or tips.

    So first I'm going to manually login to my account, go to my "watch list", view the sourcecode of DeviantArt webpage, save the sourcecode containing the urls to a file. Then I'm gonna write a small program, read that sourcecode file, get the urls, plus the file names, and tell python to retrieve it like this: www.deviantart.com/blahblah/filename?

    But I think it will be pretty hard, since in DA, When I click on the link to view the file, it only directs me to the thumbview of the file, I'll have to click on the thumbview, then it will bring me to the fullview, but the url doesnt contain the filename, so I'll have to view source again... Is there an easier way? Thanks in advance.
    What can change the nature of a man?
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Well, its definitely possible . You can use urlopen() from the urllib or urllib2 modules. Here's a small example that downloads my avatar from Devshed .

    Code:
    >>> import os, urllib
    >>> 
    >>> os.chdir('C:\Documents and Settings\Mark\Desktop')
    >>>
    >>> imageURL = 'http://forums.devshed.com/image.php?u=24289&dateline=1075854346'
    >>> 
    >>> image = urllib.urlopen(imageURL).read()
    >>> file('newImage.gif', 'wb').write(image)
    >>>
    You can ignore the os stuff - this just cd's to my desktop - since and concentrate on the urllib and file() lines.

    Enjoy,

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Questioner's home
    Posts
    89
    Rep Power
    12
    Thanks a million! =)
    What can change the nature of a man?

IMN logo majestic logo threadwatch logo seochat tools logo