Python 3 urllib.request module download? / TS3 Python Plugin

+2 Hunter Shutt · January 26, 2016
Hey guys,

I just recently got interested in Python and wanted to know if there was a download for the urllib.request module. I've tryed downloading ones off the Project Interpreter but they don't work or don't even have that specific module installed.

I'm trying to make the webcrawler and since this was a year ago, it's probably updated and it's been removed or something. So is there another module I can use for this project?

import random
import urllib.request

def download_web_image(url):
    name = random.randrange(1, 1000)
    full_name = str(name) + '.jpg'
    urllib.request.urlretrieve(url, full_name)

download_web_image('https://www.thenewboston.com/photos/users/2/resized/23471ba4417d650505928a0b1f1fd8b1.jpg')

That's what I have in the project and it can't find urllib.request.

********

I also wanted to know if anyone knows how to install this in my TS3 server, and make my own plugins/scripts?

https://github.com/nikdoof/python-ts3

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
0 Hunter Shutt · January 26, 2016
Bump..?
0 Hunter Shutt · January 26, 2016
Okay, so I guess no one knows.
0 Hunter Shutt · January 26, 2016
Ok, for everyone who DOESN'T know, this is how I fixed.


Instead of :
import urllib.request


It's this:
from urllib import urlretrieve
0 sfolje 0 · January 26, 2016
Weird ... your original code works perfect for me.
0 Hunter Shutt · January 27, 2016
We might have different versions of Python, mine is 3.4.
0 sfolje 0 · January 27, 2016
It seems like. Mine is 3.5.
0 muha hasssan · January 27, 2016
bucky, come fix this
0 sfolje 0 · January 28, 2016
I tried with python 3.4.4 right now and the code that works is original:
import random
import urllib.request

def download_web_image(url):
name = random.randrange(1, 1000)
full_name = str(name) + '.jpg'
urllib.request.urlretrieve(url, full_name)

download_web_image('https://www.thenewboston.com/photos/users/2/resized/23471ba4417d650505928a0b1f1fd8b1.jpg')

Code that doesnt works for me ((  from urllib import urlretrieve
ImportError: cannot import name 'urlretrieve' )) :
import random
from urllib import urlretrieve

def download_web_image(url):
name = random.randrange(1, 1000)
full_name = str(name) + '.jpg'
urllib.request.urlretrieve(url, full_name)

download_web_image('https://www.thenewboston.com/photos/users/2/resized/23471ba4417d650505928a0b1f1fd8b1.jpg')

Something fishy is going on. Maybe because I have installed urllib3 module. What do you get if you run "pip list" ?
0 Taiwo Kareem · February 4, 2016
For python2 it is 

import urllib2

import urllib

for python 3 do
from urllib.request import <something>
0 Sabeel Wani · February 13, 2016
import random
import urllib

def download_web_image():
url = "https://thenewboston.com/photos/users/70851/original/9a3fcea5398c7eb85ce5cc381574e33a.png"
name = random.randrange(1, 1000)
full_name = str(name) + '.jpg'
urllib.urlretrieve(url, full_name)
download_web_image()
  • 1
  • 2

Python

128,098 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator