[Pythonmac-SIG] Help with aeve

John Weeks john.weeks at insead.edu
Wed Nov 12 07:17:52 EST 2003


I am trying to use aeve for the first time and I'm impressed with how
well it works but I am not sure how to do a couple of thing.  I hope
maybe someone can help.

<background>
What I am trying to do is to automate Safari so that I can scrape search
results from LexisNexis.  LexisNexis has a particularly gnarly search
form (because of authentication issues, I think, and because of their
heavy use of JavaScript) and so I haven't found a way to direct the
searches directly from Python using urllib or ClientForm, etc.  I have
been able to write an AppleScript to use Safari to perform the search.
The problem, though, is that I need the power of something like Python
to then analyze the results and determine the next search to perform.

So, I tried osascript'ing my AppleScript from Python.  This could
probably work except that it is a serious limitation not to be able to
pass arguments to AppleScripts.  I guess I would have to have Python
create a file, dump in some arguments, and then have the AppleScript
open that file and read the arguments.  I tried that, actually, but for
some reason AppleScript did not want to read the files created by
Python.  It would read only the first two characters (and invert them,
very strange behavior).  The same script would read just fine files that
I hand-created with BBEdit.

Anyway, I started to think that aeve was a better way to go.
</background>

But I can't figure out how to do a couple of very simple things with
Safari.  I can use aeve to do things like check if windows are visible
and to see if documents exist and so on (so aeve is working and Safari
is there and listening).  But how do I do the following:

1. make new document at the beginning of documents

2. set the URL of the front document to "http://web.lexis-nexis.com/"

With 1. I have tried all kinds of things including (copying from the
iCal example on the aeve wiki):

    import aeve
    
    saf = aeve.talkto('com.apple.safari')

    from aeve.Applications import Safari
    newdoc = saf.make(new=Safari.document)
    
This gives me the following:

    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File
"/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-
packages/aeve/aetypes/aecomplex.py", line 467, in bound_event_method
        return self(inst, *args, **kwargs)
      File
"/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-
packages/aeve/aetypes/aecomplex.py", line 489, in __call__
        raise aetools.Error, aetools.decodeerror(_reply, _arguments,
_attributes)
    aeve.aetypes.aetools.Error: (6, u'NSArgumentsWrongScriptError', None
    
    
With 2. I am stumped because it seems that the URL property of the
document class is read/only.

Thanks for listening.

Cheers,
John



More information about the Pythonmac-SIG mailing list