text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
set theQueryItems to theQueryItems & {name:theComponent's |name|() as text, value:theComponent's value() as text}
|
WebLib.scpt
|
set newWebsite's queryItems to theQueryItems
|
WebLib.scpt
|
set theHTML to NSString's alloc()'s initWithContentsOfURL:theURL
|
WebLib.scpt
|
if theHTML is missing value then
|
WebLib.scpt
|
return newWebsite
|
WebLib.scpt
|
set newWebsite's HTML to theHTML as text
|
WebLib.scpt
|
set titleRegex to NSRegularExpression's regularExpressionWithPattern:"<title>(.*?)</title>" options:0 |error|:(missing value)
|
WebLib.scpt
|
set titleMatch to titleRegex's firstMatchInString:theHTML options:0 range:{0, theHTML's |length|()}
|
WebLib.scpt
|
if titleMatch is not (missing value) then
|
WebLib.scpt
|
set titleRange to titleMatch's rangeAtIndex:1
|
WebLib.scpt
|
set newWebsite's title to (theHTML's substringWithRange:titleRange) as text
|
WebLib.scpt
|
set theVisibleText to NSMutableString's stringWithCapacity:(theHTML's |length|())
|
WebLib.scpt
|
theVisibleText's setString:theHTML
|
WebLib.scpt
|
set htmlTagsRegex to NSRegularExpression's regularExpressionWithPattern:"(<head>[\\S\\s\\n\\r]*?<\\/head>|<script[\\s\\S\\n\\r]+?<\\/script>|<style[\\s\\S\\n\\r]+?<\\/style>|<a [\\s\\S\\n\\r]+?<\\/a>|<nav[\\s\\S\\n\\r]+?<\\/nav>|<link[\\s\\S\\n\\r]+?<\\/link>|<form[\\s\\S\\n\\r]+?<\\/form>|<button[\\s\\S\\n\\r]+?<\\/button>|<!--[\\s\\S\\n\\r]+?-->|<select[\\s\\S\\n\\r]+?<\\/select>|<[\\s\\n\\r\\S]+?>|&.*?;)" options:0 |error|:(missing value)
|
WebLib.scpt
|
htmlTagsRegex's replaceMatchesInString:theVisibleText options:0 range:{0, theHTML's |length|()} withTemplate:""
|
WebLib.scpt
|
set excessSpaceRefex to NSRegularExpression's regularExpressionWithPattern:"[\\s\\n\\r]+" options:0 |error|:(missing value)
|
WebLib.scpt
|
excessSpaceRefex's replaceMatchesInString:theVisibleText options:0 range:{0, length of (theVisibleText as text)} withTemplate:" "
|
WebLib.scpt
|
set newWebsite's visibleText to (theVisibleText as text)
|
WebLib.scpt
|
end websiteWithURLString:
|
WebLib.scpt
|
on Website for URLString
|
WebLib.scpt
|
return my websiteWithURLString:URLString
|
WebLib.scpt
|
end Website
|
WebLib.scpt
|
to WLWebScraper()
|
WebLib.scpt
|
script WebScraper
|
WebLib.scpt
|
property target : missing value
|
WebLib.scpt
|
on itemsWithTypes:theTypes forKeyPath:theKeyPath
|
WebLib.scpt
|
if target is missing value then
|
WebLib.scpt
|
error "Must set target"
|
WebLib.scpt
|
set theURL to NSURL's alloc()'s initWithString:target
|
WebLib.scpt
|
set theHTML to NSString's stringWithContentsOfURL:theURL encoding:(current application's NSUTF8StringEncoding) |error|:(missing value)
|
WebLib.scpt
|
set theDetector to NSDataDetector's dataDetectorWithTypes:theTypes |error|:(missing value)
|
WebLib.scpt
|
set linkArray to theDetector's matchesInString:theHTML options:0 range:{location:0, |length|:theHTML's |length|()}
|
WebLib.scpt
|
set linkArray to (linkArray's valueForKeyPath:theKeyPath)
|
WebLib.scpt
|
set linkArray to NSSet's setWithArray:linkArray
|
WebLib.scpt
|
return linkArray's allObjects() as list
|
WebLib.scpt
|
end itemsWithTypes:forKeyPath:
|
WebLib.scpt
|
on extractLinks()
|
WebLib.scpt
|
return my itemsWithTypes:32 forKeyPath:"URL.absoluteString"
|
WebLib.scpt
|
on extractPhoneNumbers()
|
WebLib.scpt
|
return my itemsWithTypes:(current application's NSTextCheckingTypeLink) forKeyPath:"URL.absoluteString"
|
WebLib.scpt
|
end extractPhoneNumbers
|
WebLib.scpt
|
on extractTransitInfo()
|
WebLib.scpt
|
return my itemsWithTypes:(current application's NSTextCheckingTypeTransitInformation) forKeyPath:"transitComponents"
|
WebLib.scpt
|
end extractTransitInfo
|
WebLib.scpt
|
on extractDates()
|
WebLib.scpt
|
return my itemsWithTypes:(current application's NSTextCheckingTypeDate) forKeyPath:"date"
|
WebLib.scpt
|
end extractDates
|
WebLib.scpt
|
on extractAddresses()
|
WebLib.scpt
|
return my itemsWithTypes:(current application's NSTextCheckingTypeAddress) forKeyPath:"addressComponents"
|
WebLib.scpt
|
end extractAddresses
|
WebLib.scpt
|
end WLWebScraper
|
WebLib.scpt
|
on webScraperForURLWithString:URLString
|
WebLib.scpt
|
set newScraper to WLWebScraper()
|
WebLib.scpt
|
set newScraper's target to URLString
|
WebLib.scpt
|
return newScraper
|
WebLib.scpt
|
end webScraperForURLWithString:
|
WebLib.scpt
|
on WebScraper for theWebsite
|
WebLib.scpt
|
return my webScraperForURLWithString:(theWebsite's URLString)
|
WebLib.scpt
|
end WebScraper
|
WebLib.scpt
|
on percentEncoding for theString
|
WebLib.scpt
|
set the theNSString to current application's NSString's stringWithString:theString
|
WebLib.scpt
|
set allowedCharacterSet to current application's NSCharacterSet's alphanumericCharacterSet
|
WebLib.scpt
|
return (theNSString's stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacterSet) as text
|
WebLib.scpt
|
end percentEncoding
|
WebLib.scpt
|
on percentDecoding for theString
|
WebLib.scpt
|
set theNSString to current application's NSString's stringWithString:theString
|
WebLib.scpt
|
return (theNSString's stringByRemovingPercentEncoding()) as text
|
WebLib.scpt
|
end percentDecoding
|
WebLib.scpt
|
property lngsyncPath : "/Applications/LNGoogleCalSync/"
|
LNGoogleCalSync-Launcher.applescript
|
property lngsyncFilePath : lngsyncPath & "lngsync.sh"
|
LNGoogleCalSync-Launcher.applescript
|
set shellOutput to do shell script lngsyncFilePath
|
LNGoogleCalSync-Launcher.applescript
|
if shellOutput does not contain "Running Lotus Notes Google Calendar Sync in GUI mode..." then
|
LNGoogleCalSync-Launcher.applescript
|
scriptError(shellOutput)
|
LNGoogleCalSync-Launcher.applescript
|
scriptError(errStr)
|
LNGoogleCalSync-Launcher.applescript
|
on scriptError(errorMessage)
|
LNGoogleCalSync-Launcher.applescript
|
set myPath to (path to me as text)
|
LNGoogleCalSync-Launcher.applescript
|
display alert "Application not found" message "Application could not be started from
|
LNGoogleCalSync-Launcher.applescript
|
" & lngsyncFilePath & "
|
LNGoogleCalSync-Launcher.applescript
|
because of error
|
LNGoogleCalSync-Launcher.applescript
|
" & errorMessage & "
|
LNGoogleCalSync-Launcher.applescript
|
if response is "Edit Script" then try
|
LNGoogleCalSync-Launcher.applescript
|
tell application "Script Editor" to open myPath
|
LNGoogleCalSync-Launcher.applescript
|
end scriptError
|
LNGoogleCalSync-Launcher.applescript
|
property name : "date"
|
+date.applescript
|
property id : "chrisk.applescript.lib:date"
|
+date.applescript
|
property UnixEpoch : {year:1970, month:January, day:1}
|
+date.applescript
|
property AppleEpoch : {year:2001, month:January, day:1}
|
+date.applescript
|
to make at {year:y, month:m, day:d} ¬
|
+date.applescript
|
given time:{hours:h, minutes:mm, seconds:s} ¬
|
+date.applescript
|
: {hours:0, minutes:0, seconds:0}
|
+date.applescript
|
local y, m, d, h, mm, s
|
+date.applescript
|
tell (the current date) to set ¬
|
+date.applescript
|
[ASdate, year, day, its month, day, time] to ¬
|
+date.applescript
|
[it, y, 1, m, d, h * hours + mm * minutes + s]
|
+date.applescript
|
ASdate
|
+date.applescript
|
on ISOdate from ASdate as date
|
+date.applescript
|
ASdate as «class isot» as string
|
+date.applescript
|
return {date string:text 1 thru 10 ¬
, time string:text 12 thru 19} of the result
|
+date.applescript
|
set [y, m, d, t] to [year, month, day, time string] of ASdate
|
+date.applescript
|
return [the contents of [y, ¬
|
+date.applescript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.