使用 javascript 和 applescript 在网页上提交数据
我正在尝试在我正在编写的 applescript 中使用 javascript (do javascript) 登录网站。我已经能够使用 (document.getElementById) 解析数据,但我找不到任何能够发送数据以便将数据输入到网页和/或登录的内容。
我正在使用的元素是:
<input style="width:80%;" type="text" name="ssn" id="ssn">
<input type="password" name="password" style="width:80%;">
<input type="radio" value="current" name="period" checked="checked">
<input type="submit" value="Submit" name="Action">
第一个位是我的用户名,接下来是我的密码,然后是用于选择我的登录类型的单选按钮,然后是提交按钮。
如果有办法做到这一点,任何帮助将不胜感激。
谢谢
I am trying to log into a website using javascript (do javascript) in an applescript I am writing. I have been able to parse data using (document.getElementById) but I can't find anything to be able to send data in order to input data to the webpage and or to log in.
The elements I am working with are:
<input style="width:80%;" type="text" name="ssn" id="ssn">
<input type="password" name="password" style="width:80%;">
<input type="radio" value="current" name="period" checked="checked">
<input type="submit" value="Submit" name="Action">
First bit is my username, the next my password, after that a radio button that is for selecting my log in type and then the submit button.
If there is anyway to do this any help would be greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的博客中有一个在联邦快递填写表格的示例。
http://www.libertypages.com/clarktech/?page_id=1570
其中我不提交表单(因为我通常想先检查提交情况)。我最近将其修改为自动提交,尽管我还没有编写该脚本。然而添加很简单。在联邦快递,您只需执行以下操作。 (您可以将其添加到上面链接的脚本中)
Safari.do_JavaScript(u"document.getElementById('completeShip.ship.field').click()", in_=FEdoc)
这将通过 ID 获取提交按钮,然后单击它。如果网站使用 ID,您应该能够轻松地将其修改为您的脚本。
请注意,以上所有内容都使用 Appscript 和 Python。 (我最喜欢的脚本环境)要在纯Applescript中执行此操作,您只需将上面的内容更改为类似的内容
I have an example of filling in forms at FedEx at my blog.
http://www.libertypages.com/clarktech/?page_id=1570
In that script I don't submit the form (since I normally want to check over the submission first). I recently modified it to auto-submit although I've not written up that script yet. However the addition is simple. At FedEx you just do the following. (You can add this to the script linked to above)
Safari.do_JavaScript(u"document.getElementById('completeShip.ship.field').click()", in_=FEdoc)
This gets the submission button by ID and then clicks it. You should be able to easily modify this to your script if the website utilizes IDs.
Note that all the above uses Appscript and Python. (My favorite scripting environment) To do this in pure Applescript you just change the above to something like