MAC vendor lookup: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Thundergnat moved page MAC Vendor Lookup to MAC vendor lookup: capitalization policy (don't know how I missed this one for so long...)) |
(→{{header|AppleScript}}: Do the appending and delaying in AS instead of shell) |
||
Line 63: | Line 63: | ||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
This is the first implementation to build in a delay between two calls to avoid throttling by macvendors.com. The version below is the as-typed one : |
|||
<lang AppleScript> |
<lang AppleScript>set apiRoot to "https://api.macvendors.com" |
||
set |
set macList to {"88:53:2E:67:07:BE", "D4:F4:6F:C9:EF:8D", ¬ |
||
⚫ | |||
set table to {} |
|||
repeat with burger in macList |
repeat with burger in macList |
||
set end of table to do shell script "curl " & apiRoot & "/" & burger |
|||
delay 1.5 |
|||
end repeat |
end repeat |
||
set text item delimiters to linefeed |
|||
return table as string |
return table as string |
||
</lang> |
</lang> |
||
If this is part of a larger script you probably want to save and restore the text item delimiters: |
|||
Which will turn into the one below once it is compiled. Script Editor translates \n to a newline in the code itself. |
|||
<lang AppleScript> |
|||
⚫ | |||
<lang applescript>set savedTID to text item delimiters |
|||
repeat with burger in macList |
|||
set text item delimiters to linefeed |
|||
set end of table to do shell script "curl http://api.macvendors.com/" & burger & " && sleep 5 && echo ' |
|||
⚫ | |||
'" & return |
|||
set text item delimiters to savedTID |
|||
end repeat |
|||
return tableText</lang> |
|||
⚫ | |||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
" |
|||
Intel Corporate |
Intel Corporate |
||
Apple, Inc. |
Apple, Inc. |
||
Line 94: | Line 93: | ||
PEGATRON CORPORATION |
PEGATRON CORPORATION |
||
Dell Inc. |
Dell Inc. |
||
" |
|||
</pre> |
</pre> |
||