More actions
imported>trailblaze No edit summary |
imported>trailblaze No edit summary |
||
| Line 30: | Line 30: | ||
import urllib | |||
import urllib2 | |||
req = urllib2.Request('http://9632024.tistory.com/974') | |||
try: urllib2.urlopen(req) | |||
except URLError, e: | |||
print e.reason | |||
fo = open("test1.html","w") | |||
for line in urllib2.urlopen(req).readlines(): | |||
fo.write(line) | |||
fo.close() | |||
* http://coreapython.hosting.paran.com/howto/HOWTO%20Fetch%20Internet%20Resources%20Using%20urllib2.htm | |||
=== 소스에서 URL만 추출하기 === | === 소스에서 URL만 추출하기 === | ||
Revision as of 23:52, 14 July 2012
목적
Python을 이용해서 Web Crawler를 제작하면서 Python의 사용법을 익히고, 원하는 웹 페이지를 긁기 위한 Web Crawler를 제작한다. (네이버웹툰(돌아온 럭키짱, 신의 탑...), 네이버 캐스트, 그 외의 각종 웹페이지..)
필요기술
- HTML
- CSS
- JavaScript
- Python
HTML, CSS, JavaScript - 웹 페이지 분석 Python
진행 과정
필요한 문서
시작
웹 페이지 소스 긁어오기
import urllib
import urllib2
req = urllib2.Request('http://9632024.tistory.com/974')
try: urllib2.urlopen(req)
except URLError, e:
print e.reason
fo = open("test1.html","w")
for line in urllib2.urlopen(req).readlines():
fo.write(line)
fo.close()