Can someone tell me why this won't put all the ten image files on the desktop. I can't just put it in the code format because Sup Forums thinks its spam due to all the links, but here's a pastebin:
pastebin com/gyuAK1Z5
Can someone tell me why this won't put all the ten image files on the desktop...
Other urls found in this thread:
media.timesreview
media.timesreview.com.s3.amazonaws.com
twitter.com
Desktop
You need path too maybe. C://
Why the random?
youareapieceofshit.jpg
Desktop works fine
the path is fine
Just because
Ok it seems I didn't explain well enough. The program works but rather then putting a file on the desktop ten times like it is supposed to, it does it a random amount of times each time I run it. Sometimes it will do all ten, sometimes it will only do three, my question is why
Some of your urls are malformed, I'm surprised requests isn't crashing your interpreter to let you know about it.
It's because of the random. You're downloading some more than once and overwriting it.
If you don't believe me, print out the URL instead of downloading it. Then try this for your loop
for index, pic in enumerate(pics):
Also some URLs are broken. Also did you just bait us all? It's okay if you did
No, because of his for loop he's saving
1.png
2.png
3.png
etc, to his desktop. He's not saving on top of anything.
I still say op should try fixing his URL's
I tried all the urls, they work fine
what do you mean by fix the urls?
Well, hang on. The pastebin has the urls looking better. Which one are you trying to run op?
The one in pastebin
I took out the periods for the one in the pic to see if i could post it without getting the spam protection
In your screenshot your URL's look like this
>media.timesreview com.s3.amazonaws.com/riverheadnewsreview/files/Ramen.jpg
Instead of
>media.timesreview.com.s3.amazonaws.com
there should be a dot between timesreview and com
You're right, I'm wrong. The random won't guarantee all unique pictures, but there will be ten files.
Yea I know, I tried to post without the periods to get rid of spam protection but it didnt work
I know they won't all be unique, I just wan't ten pictures selected randomly to be put on the desktop ten times. Some times it will do it ten times, sometimes it will only do it 5 times. The problem is I have no clue why
It's ok man, even the best programmers in the world struggle to read code written by others.
OP, I ran your code. I have "0.png" -> "9.png" on my desktop in python27.
delete them and run it again, if it's anything like mine it will vary on the amount it puts on the desktop
...
...
wow, so I guess it's just my comp, well thanks
Could it be your internet connection?
Try cranking sleep up to 3
nah, I got the ethernet cable plugged in, definetly not the internet
Try it anyways. The code might be running faster than the download so it just abandons it when the next call to requests is made.
Think about it. Every Time you call requests.get, you are erasing the previous request.
Nevermind, I tried turning mine down and I can't repeat your problem.