»Ë»Ñ Æ÷·³
°³¹ßÀÚÆ÷·³ ÀÔ´Ï´Ù.
  • ºÏ¸¶Å© ¾ÆÀÌÄÜ

ÆÄÀ̽ã ÄÚµùÁ» ºÁÁֽǺÐ.. ÀÚ²Ù ¿À·ù°¡ ³ª³×¿ä2

  • [* ºñȸ¿ø *]
  • µî·ÏÀÏ 2016-01-22 17:26
  • Á¶È¸¼ö 1533
µð½Ã °¶·¯¸®¿¡¼­ À̹ÌÁö¸¦ ±Ü¾î¿À´Â Å©·Ñ¸µÀ» ¸¸µé·Á´Âµ¥
½ÇÇàÇÏ¸é ¿À·ù°¡ ³ª³×¿ä

import urllib
from urllib import request
import requests
from bs4 import BeautifulSoup
from socket import timeout

site='http://gall.dcinside.com/board/view/?id=iu_new&no='
fileNo = 0
try:
        for no in range(1778524, 1778548):
                url=site+str(no)
                source_code=requests.get(url)
                plain_text=source_code.text
                soup=BeautifulSoup(plain_text,'lxml')
                iu=soup.find_all('li',{'class':"icon_pic"})
                print(iu)
                for url in iu:
                        href=url.get('href')
                        contents=urllib.request.urlopen(href)
                        content=contents.read()
                        open(str(fileNo)+'.jpg','wb').write(content)
                fileNo=fileNo+1
except timeout:
        print('shit')
else:
        print('success')

<½ÇÇà½Ã ¿À·ù>
Traceback (most recent call last):
  File "C:/Users/beench/Desktop/co/racing.py", line 19, in
    contents=urllib.request.urlopen(href)
  File "C:\Anaconda3\lib\urllib\request.py", line 162, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Anaconda3\lib\urllib\request.py", line 456, in open
    req.timeout = timeout
AttributeError: 'NoneType' object has no attribute 'timeout'

ã¾Æº¸´Ï±ñ urllib.request.urlopen(href) ºÎºÐÀÌ ¹®Á¦ÀΰŠ°°Àºµ¥ ÇØ°áÃ¥À» ¸ð¸£°Ú³×¿ä

0
ÃßõÇϱ⠴ٸ¥ÀÇ°ß 0
|
°øÀ¯¹öÆ°

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 ¿¡½ºÅ×¹Ýa

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 [* ºñȸ¿ø *]
  • ¾Ë¸² ¿å¼³, »óó ÁÙ ¼ö ÀÖ´Â ¾ÇÇÃÀº »ï°¡ÁÖ¼¼¿ä.
©¹æ »çÁø  
¡â ÀÌÀü±Û¡ä ´ÙÀ½±Û ¸ñ·Ïº¸±â