Jump to content

i dont understand?!?!?!

- - - - -

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

#1
Hot_Milo23

Hot_Milo23

    Programmer

  • Members
  • PipPipPipPip
  • 120 posts
ive sort of brought this issue up on another thread, but i thought i might open it up here too.
i can find absolutely no explanation why this code works for some images and not others. if anyone could help it would be much appreciated.

from urllib import urlretrieve

url=str(raw_input("URL: "))

name="img1.png"

file = open(name, 'w')

urlretrieve(url, name)

file.close()


so the code asks for the url of a picture off the net, converts it to png, and saves it as img1.png. i went to google and saved the logo ->worked fine.
tried saving other images from around the web ->no problems.
but when i try to save ANY images from this site:
Pokmon-X
I dont understand why!!!
so, any ideas?

#2
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
First image I see
http://pokemonx.comi...cs/20090429.png
No problem poking it with python,
perhaps you're not entering the right url, or the right image name...
If I were you, I'd write a html parser that scans for the right images using regex, but I guess I like to complicate things uselessly ;) .

#3
Hot_Milo23

Hot_Milo23

    Programmer

  • Members
  • PipPipPipPip
  • 120 posts
when i use that url i get a 1x1 pixel??
same as all the other ones i try.
and im copying and pasting the urls into the program.
:(

#4
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
Hum, actually, why do you open a file???
I just checked the man, you dont even need to pass a file object, just the local filename is enough for the second argument.

#5
Hot_Milo23

Hot_Milo23

    Programmer

  • Members
  • PipPipPipPip
  • 120 posts
Posted via CodeCall Mobile
soz, im not following u? Can u explain?

#6
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
you do not need to do:
f=file(name,"w")
urlretr(...) #your not even passing f as an arg here
f.close()

just do urlretreive.

#7
Hot_Milo23

Hot_Milo23

    Programmer

  • Members
  • PipPipPipPip
  • 120 posts
Posted via CodeCall Mobile
ok. But should that really stop some pics downloading and not others?

#8
Hot_Milo23

Hot_Milo23

    Programmer

  • Members
  • PipPipPipPip
  • 120 posts
Posted via CodeCall Mobileok, well, i.ll have anotha look in the morning when im fresh eyed. Thx manux. :)

#9
givislo

givislo

    Newbie

  • Members
  • Pip
  • 1 posts
The best that go together.

#10
Excited

Excited

    Newbie

  • Members
  • PipPip
  • 27 posts
that is because this only works for .png images and not .jpg, jpeg, .gif, etc etc

#11
manux

manux

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 234 posts
huh... no?
Why would it only work with pngs?
It's just a file which he retrieves and save on his HD...