Jump to content

hacking an image downloader ...

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
8 replies to this topic

#1
Kousuke

Kousuke

    Newbie

  • Members
  • PipPip
  • 14 posts
[ATTACH]3164[/ATTACH]

i' m trying to change an existing script
for my own needs

but the script doesn't work on my comp :P
So I thought i could change it
but my beginner knowledge of python isn't good enough for that :sleep:

the original script is here:
Download image file from the HTML page source using python? - Stack Overflow

first i want to get it to work
then i want to add some extra features to it

what i get when i run it:
Errorno2 no such file or directory

when i change
urlretrieve(urlparse.urlunparse(parsed), outpath)
to
urlretrieve(urlparse.urlunparse(parsed), test.jpg)

it does work a bit :p
it doesn't complain but the file was corrupted

so new thoughts are welcome :)

#2
Kousuke

Kousuke

    Newbie

  • Members
  • PipPip
  • 14 posts
a status update:
i've rewrited the existing code
in something more readable
the next step I wan't to do is know more about
binary file handling of jpg,png en gif files

#3
Kousuke

Kousuke

    Newbie

  • Members
  • PipPip
  • 14 posts
[ATTACH]3174[/ATTACH]

Status update #2:

I simple forgot some brackets in the code
saving an image works now :sleep:

now saving the image in a relative map is the next goal :cool:

Attached Files



#4
lemontree

lemontree

    Newbie

  • Members
  • Pip
  • 2 posts
saving an image works now

#5
Kousuke

Kousuke

    Newbie

  • Members
  • PipPip
  • 14 posts
[ATTACH]3333[/ATTACH]

the use of a relative map is implemented

#6
Kousuke

Kousuke

    Newbie

  • Members
  • PipPip
  • 14 posts
I wanted to make the code fully compatible with python3
After several hours working on the script
Using lxml instead of beautifulsoup
lxml is a collection of scripts processing html or xml
I used lxml.html together with xpath
I made succesful a frozen binary too
which you may get from my site
I'm still not very pleased with the limited things it can do
but i'll make it something good :)

the next project I'm starting will use the flickr api for downloading your images
still don't get your hopes up...
If you're interested in what I'm doing or have done:
Check my blog
kousuke-myblog

#7
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Nice work Kousuke.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#8
Kousuke

Kousuke

    Newbie

  • Members
  • PipPip
  • 14 posts
Thanks :c-grin:

I'm currently still learning python
(learning python writed by mark lutz)
I have some ideas in which direction I want to go with programming

im interested in using xmpp later and pyqt
for a type of program that can be improved in my opinion
(I'm not going in to details yet , again from this stage I can't promise anything)
If you're interested in what I'm doing or have done:
Check my blog
kousuke-myblog

#9
Kousuke

Kousuke

    Newbie

  • Members
  • PipPip
  • 14 posts
Here is the new improved script
the most important fixes are the command line setup
and the use of raw strings for file directories

dumpimagesWIP5.py
dumpimages0.3WIP5.py
If you're interested in what I'm doing or have done:
Check my blog
kousuke-myblog