2009-12-14 13 views
5

Sono a conoscenza di domande precedenti relative a mechanize + Google App Engine, What pure Python library should I use to scrape a website? e Mechanize and Google App Engine.Python Mechanize + codice GAEpython

Inoltre v'è un certo codice here, che non posso andare al lavoro sul motore app, gettando

File “D:\data\eclipse-php\testpy4\src\mechanize\_http.py”, line 43, in socket._fileobject(”fake socket”, close=True) 
File “C:\Program Files (x86)\Google\google_appengine\google\appengine\dist\socket.py”, line 42, in _fileobject 
fp.fileno = lambda: None 
AttributeError: ’str’ object has no attribute ‘fileno’ 
INFO 2009-12-14 09:37:50,405 dev_appserver.py:3178] “GET/HTTP/1.1″ 500 - 

C'è qualcuno disposto a condividere la loro mechanize di lavoro + Codice appengine?

risposta

1

sono riuscito a ottenere meccanizzare il codice che gira su GAE, molte grazie a MStodd, dal progetto GAEMechanize http://code.google.com/p/gaemechanize/ e

Se qualcuno ha bisogno del codice, è possibile contattare MStodd!

ps: il codice non è su Google Code, quindi bisogna contattare il proprietario ..

Acclamazioni don

10

ho risolto questo problema, basta cambiare il codice di mechanize._http.py , sulla linea 43, da:

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) 

a:

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

grazie! - ha funzionato per me – hoju

+10

al momento è necessario andare in _urllib2_fork.py – hoju

+0

Se provi a farlo fin da ora (dic 2011) non è nello stesso file ma in urllib2 – lc2817

Problemi correlati