在 OSX 中自动化 HTTP GET/POST
我需要每小时在路由器上释放我的 IP 地址。路由器页面需要简单的身份验证和单击按钮来完成该过程。这些是 HTTP 调用:
单击“验证
GET /RST_st_dhcp.htm HTTP/1.1
Host: 10.10.1.1
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
发布”按钮
POST /st_dhcp.cgi?id=1044071018 HTTP/1.1
Host: 10.10.1.1
Content-Length: 31
Cache-Control: max-age=0
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
Origin: http://10.10.1.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://10.10.1.1/RST_st_dhcp.htm
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
connect=Release&refreshScrn=yes
如何在 OSX 中自动执行此操作?是否可以为此编写自动化脚本?
I need to release my IP address at the router on an hourly basis. The router page needs simple authentication and a button click to do the process. These are the HTTP calls:
Authenticate
GET /RST_st_dhcp.htm HTTP/1.1
Host: 10.10.1.1
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Release button click
POST /st_dhcp.cgi?id=1044071018 HTTP/1.1
Host: 10.10.1.1
Content-Length: 31
Cache-Control: max-age=0
Authorization: Basic YWRtaW46cGFzc3dvcmQ=
Origin: http://10.10.1.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Referer: http://10.10.1.1/RST_st_dhcp.htm
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
connect=Release&refreshScrn=yes
How can this be automated in OSX? Is it possible to write automator scripts for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以简单地使用
curl
来发出该请求 - 例如您需要检查URL中的
id
是否重要。如果没有,以上应该就是您所需要的。如果是这样,那么您可能必须发出第一个请求才能从其负载中获取id
。You can simply use
curl
to make that request - something likeYou'll need to check whether the
id
in the URL matters. If not, the above should be all you need. If it does then you may have to make the first request to get theid
from its payload.