- 论坛徽章:
- 0
|
- import re
- import urllib
- import sys
- from cgitb import html
- def get(url):
- page = urllib.urlopen(url)
- html = page.read()
- return html
-
- def getima(html):
- res = r'src="//(.*\.png)"'
- # <img width="890" height="440" src="//img.alicdn.com/tps/i4/TB16yXvHFXXXXXkXVXXblszJFXX-890-440.png" alt="" />
-
- ress = re.compile(res)
- list_ima = ress.findall(html)
- print list_ima
- i = 0
- for x in list_ima:
- print x
- print'------------------------------------------'
- try:
- urllib.urlretrieve(x,'%s.jpg' % i)
- except:
- print "Unexpected error:", sys.exc_info()[0]
- i+=1
- print '%s has been downloaded' % i
-
- html = get("mm.taobao.com")
- getima(html)
复制代码 错误信息:Unexpected error: <type 'exceptions.IOError'>
请问我应该怎么改正? |
|