Fellow BBEditors,
I could use Script Debugger 4.5 to explore more of what is going-on with my
search from yesterday and the results. The Explore feature was very useful
to see what AppleScript could find after BBEdit executed my grep "Find All"
search (repeated below for convenience). In short: it does find the search
results browser as I expected. However, the browser window does not provide
all values that the script dictionary knows about. Those would be exactly
what I am trying to extract from the search.
In more detail, after my (complicated) search finding 154 occurrences,
Script Debugger produced this error instead of the values for "contents",
"file", "properties" and "selection" of "search results browser 1": "Get
failed: no such object (e.g. ...) errAENoSuchObject:-1728". For "document"
and "text" of the same, it told me that "An attempt was made to resolve an
Apple Event reference to a non-existent object (MacOS error
code:-1728)(-1728)".
I would be glad if somebody could tell me what's going on and whether there
is a way out/around.
Thanks again,
Laszlo
PS: My search in AppleScript was:
find "(?<=href=\")((\\S*)(\\.pdf))|((\\S*)(harvard.edu)(\\S*))(?=\")"
searching in front document options {search mode:grep, starting at top:true,
wrap around:false, backwards:false, case sensitive:false, match words:false,
extend selection:false} with selecting match
2009/9/6 László Sándor
> Hi all,I'm new to both BBEdit and AppleScript, so please forgive my
> ignorance. But let me also say that I spent the better half of my Sunday
> trying to resolve this issue, which also might say something about the
> documentation of BBEdit scripting (or implementation, or a bug).
>
> I wanted to have a script that goes through all the links on a website and
> downloads the pdfs linked in. (FYI, download managers did not work, as the
> course websites at my university require authentication, and somehow only a
> browser could manage that. I'd be glad if, say, DownThemAll would quickly do
> the job in Firefox, but it cannot.)
>
> I have the simple script below to ask for the URL, then grab the source,
> then look for the right pattern. I'm sort of proud having the right grep
> pattern to extract the links. Surprisingly, I could not figure out how to
> use the result coming from BBEdit. The user's manual is almost completely
> silent on the most complicated search-scripting issue (i.e. multi-file
> search), the AppleScript Editor under Snow Leopard cannot open the
> dictionaries of BBEdit or TextWrangler, but even now that Script Debugger
> could, I cannot parse how I could use result of a multi-file search (a bit
> of success/failure or a "search results browser" window ID). I could not use
> search results browser window to do any work.
>
> Thank you for looking into this, any help would be greatly appreciated. I
> am aware of some messages from earlier this year when Jeff tried to do
> something similar, but apparently exchanged three emails with himself on
> this list without resolving the issue. Some clarification could benefit the
> whole community.
>
> Thanks,
>
> Laszlo
>
> The script:
>
> display dialog "What is the URL of the course readings site with the PDF
> links?" default answer ""
> set theURL to the text returned of the result
> tell application "WebKit"
> set the URL of the front document to theURL
> set theText to the source of front document
> end tell
>
> -- set listOFlinks to {}
> tell application "BBEdit"
> make new document
> set text of front document to theText
> set fndResults to match list window of (find
> "(?<=href=\")((\\S*)(\\.pdf))|((\\S*)(harvard.edu)(\\S*))(?=\")" searching
> in front document options {search mode:grep, starting at top:true, wrap
> around:false, backwards:false, case sensitive:false, match words:false,
> extend selection:false})
> -- get properties of fndResults
> -- get contents of fndResults
> get text of fndResults
> (*
> repeat with i from 1 to count of items in fndResults
> set this_item to result_file of item i of fndResults
> copy this_item to end of listOFlinks
> end repeat
> *)
> end tell
>
> tell application "WebKit"
> repeat with i from 1 to count of items in listOFlinks
> set the URL of the front document to i
> save document 1
> end repeat
> end tell
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem,
please email "supp...@barebones.com" rather than posting to the group.
-~--~~~~--~~--~--~---