Python Mechanize + GAEpython code

前端 未结 3 549
陌清茗
陌清茗 2020-12-08 18:13

I am aware of previous questions regarding mechanize + Google App Engine, What pure Python library should I use to scrape a website? and Mechanize and Google App Engine.

相关标签:
3条回答
  • 2020-12-08 18:23

    I have solved this problem, just change the code of mechanize._http.py, about line 43, from:

    try:
        socket._fileobject("fake socket", close=True)
    except TypeError:
        # python <= 2.4
        create_readline_wrapper = socket._fileobject
    else:
        def create_readline_wrapper(fh):
            return socket._fileobject(fh, close=True)
    

    to:

    try:
        # fixed start -- fixed for gae
        class x:
            pass
    
        # the x should be an object, not a string,
        # This is the key
        socket._fileobject(x, close=True)
        # fixed ended
    except TypeError:
        # python <= 2.4
        create_readline_wrapper = socket._fileobject
    else:
        def create_readline_wrapper(fh):
            return socket._fileobject(fh, close=True)
    
    0 讨论(0)
  • 2020-12-08 18:32

    I managed to get mechanize code that runs on GAE, many thanks to MStodd, from GAEMechanize project http://code.google.com/p/gaemechanize/ and

    If anybody needs the code, you can contact MStodd !

    ps: the code is not on google code, so you have to contact the owner..

    Cheers don

    0 讨论(0)
  • 2020-12-08 18:33

    I've uploaded the source of the gaemechanize project to a new project: http://code.google.com/p/gaemechanize2/

    Insert usual caveats.

    0 讨论(0)
提交回复
热议问题