[英]Get Image URL/Address from webpage selection using Applescript/Javascript
I need a quick way to get the image URL, just like I would get if I right click on an image and select "Copy Image URL". 我需要一种快速的方法来获取图像URL,就像我右键单击图像并选择“复制图像URL”一样。 I'm thinking Applescript, though others have mentioned Javascript.
我在想Applescript,尽管其他人也提到Javascript。
This needs to be compatible with an Automator workflow and needs to work with Google Chrome, Chromium, and Safari, at a minimum. 这必须与Automator工作流程兼容,并且至少需要与Google Chrome,Chromium和Safari兼容。
More specifics: 更多细节:
The basic logic is this: 基本逻辑是这样的:
Does selected input contain images?
If yes,
get URL of image(s)
pass to the next step
else continue
Any help or ideas appreciated! 任何帮助或想法表示赞赏!
OS X Services would be your best bet. OS X服务将是您最好的选择。 Those work with text selections and are supported in most apps (eg see the Safari>Services submenu).
这些选项可使用文本选择,并且在大多数应用程序中受支持(例如,请参见Safari>“服务”子菜单)。 You can also assign them keyboard shortcuts, which is very handy for repetitive tasks.
您还可以为其分配键盘快捷键,这对于重复性任务非常方便。
Basically, you want to get the selection as web content (ie HTML data, not plain text) then extract the URLs from that. 基本上,您希望将选择内容作为Web内容(即HTML数据,而不是纯文本)获取,然后从中提取URL。 You can create services in Automator, which includes various actions for working with web content, so I recommend starting there.
您可以在Automator中创建服务,其中包括用于处理Web内容的各种操作,因此我建议从那里开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.