2009년 9월 23일 수요일

파이썬에서 웹페이지 긁어 오기

php에는 아래와 같은 snoopy 라는 강력한 라이브러리가 있다.
[강좌] php용 강력하면서 쉬운 소켓(socket)클래스 , Snoopy

 

파이썬에는 없는 것일까? 찾아 보자.

1. BeautifulSoup 이라는 라이브러리가 있음.

2. 1.의 라이브러리는 느리다는 평이 있다.  아래는 직접 작업하기

[파이썬마을]특정 웹페이지의 링크의 일부 가져오기 (기본적인 답변)

[파이썬마을]urllib 모듈로 그림까지 가져오려면?? (쓸만한 답변코드 있음)

#! /usr/local/bin/python
# ex:ts=4
import urllib, urlparse
import re, os.path, os
urlfind1 = re.compile(r'[<](\w*)[^>]*[Ss][Rr][Cc]=([^"\' ]\S*)[^>]*[>]')
urlfind2 = re.compile(r'[<](\w*)[^>]*[Ss][Rr][Cc]=["\']([^"\']*)["\'][^>]*[>]')
def recurget(url, got=None, depth=0):
    if got is None: got = []
    print "   "*depth + "Getting %s ..." % url
    content = urllib.urlopen(url).read()
    urls = urlfind1.findall(content) + urlfind2.findall(content)
    filepath = urlparse.urlparse(url)[2][1:]
    try:
        os.makedirs(os.path.dirname(filepath))
    except OSError:
        pass
    open(filepath, "w").write(content)
    for tag, target in urls:
        turl = urlparse.urljoin(url, target)
        print "   "*depth + " + Tag found (%s to %s) => %s" % (tag, target, turl)
        if turl not in got:
            got.append(turl)
            recurget(turl, got, depth+1)
if __name__ == "__main__":
    import sys
    for url in sys.argv[1:]:
        recurget(url)

 

Python File Read Write with Urllib2

android 3D engine

동영상은 흐리다.  더 밝은 동영상이 youtube에도 아직 없다.
Video overcast. This youtube video has not yet even brighter.

http://rokon-android.blogspot.com/

http://code.google.com/p/rokon/

2009년 9월 19일 토요일

2009년 9월 11일 금요일

App Engine 기본구조 - 간단예제

 

기본 구조는 세 부분으로 구성되어 있다.

1. RequestHandler 클래스로 하나이상의 요청과 답변 처리

2. WSGIApplication 인스턴스로 URL을 통해 들어오는 요청을 처리

3. CGI Adapter로 WSGIApplication 메인루틴 실행

 

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app


class MainPage(webapp.RequestHandler): #클래스 선언
  def get(self): #함수의 선언
    self.response.headers['Content-Type'] = 'text/plain'
    self.response.out.write('Hello, webapp World!')
    #여기가 함수의 종료점(파이썬은 띄어쓰기로 구분)
 
#'/' 로 들어 오는 요청을 MainPage 클래스와 연결
application = webapp.WSGIApplication(
                                     [('/', MainPage)],
                                     debug=True)

def main(): #메인루틴 실행 함수
  run_wsgi_app(application) #위에서 선언한 application을 실행함.

if __name__ == "__main__":
  main()
 
결과:
 

[관련글]
Hello, World! - Getting Started: Python - Google App Engine 
파이썬 구글 엡엔진 이클립스 개발환경 
Google App Engine 

2009년 9월 2일 수요일

ARCHOS 안드로이드 타블렛 PMP

Archos 타블렛 PMP 안드로이드 버젼

Archos 안드로이드 테블릿 가격이 16GB ($293), 32GB ($369), 160GB ($319), 500GB ($419)로 결정

아래는 이전 버젼 리뷰 - 성능은 괜찮은것 같음
























배터리는 얼마나 가는지가 매우 궁금함.


[관련글]

요즘 안드로이드 개발에 푹빠지다 

안드로이드 API Demos : Views/Animation 

안드로이드에서 720P 비디오 구동화면