使用curl&在网页上按javascript按钮;重击 [英] Press javascript button on webpage using curl & bash
问题描述
我在这里的第一篇文章,所以如果在其他地方回答此主题,请告诉我.我找到了类似的帖子,但没有设法用它们来解决我的问题.
My first post here, so please if this topic is answered elsewhere let me know. I found similar posts but didn't manage to use them to solve my problem.
背景:我使用的IPTV服务提供商可以在运行KODI的RPi上观看电视频道.因此,该提供商促进IPTV简单客户端以及一些播放列表网址的使用.简而言之,此播放列表仅为我的帐户生成,并绑定到我的公共IP地址.问题,我没有并且想要有一个固定的公共IP地址,因此每次我的ISP重置我的DSL连接时,我都必须登录IPTV提供程序页面并按所谓的更新IP"按钮.真烦人!我想使用bash脚本来自动执行该操作,该脚本由动态dns服务更新触发,该更新定期在我的rpi上运行.
Background: I use a IPTV service provider which offers the possibility to watch TV Channels on my RPi running KODI. SO this provider promotes usage of a IPTV Simple Client together with some playlist urls. Making thinks shorter, this playlists are generated for my account only and are bound to my public IP address. Problem, I don't have and want to have a fix Public IP address, so everytime my ISP resets my DSL connection I have to login on the IPTV provider page and press on a so called "Update IP" button. That's annoying!! I want to automate that with a bash script which would be triggered by my dynamic dns service update which runs on a regular basis on my rpi.
我到目前为止所管理的:-使用带有CURL的bash命令登录网页并将Cookie保存到文本文件中.与此:
What I managed so far: - use a bash command with CURL to login on the webpage and save the cookie into a text file. with this:
curl -c cookie.txt -d "user=mymail@mail.com" -d "pass=mypass" http://www.spicetvbox.ro/user/login
然后我尝试了几种方法来按以下方式按下该更新IP"按钮:
And then I tried several ways to press that "Update IP" button with:
curl -b cookie.txt -d "press=UPDATEIP" http://www.spicetvbox.ro/user/xbmc
curl -b cookie.txt -d "button=Upfate IP" http://www.spicetvbox.ro/user/xbmc
curl -b cookie.txt -X POST http://www.spicetvbox.ro/user/xbmc
以及其他类似的命令.我试图用萤火虫检查按钮元素.这是firebug的html:
And allot of other commands like this. I tried to use firebug to inspect the button element.. and this is the html from firebug:
<form id="formXBUpd89942" class="jqValidation" role="form" novalidate="novalidate" action="http://www.spicetvbox.ro/user/xbmc" method="post">
<input type="hidden" value="UPDATEIP" name="run">
<input type="hidden" value="89942" name="id">
<button class="btn btn-info btn-xs" type="submit">
<i class="fa fa-refresh"></i>
Update IP
</button>
请给我一些有关如何从CURL按下该按钮的建议.
Please give me some advice on how to press that button from CURL.
推荐答案
您实际上不需要单击按钮-您需要提交表单,或者至少达到相同的效果.
You don't really need to click the button - you need to submit the form, or at least achieve the same effect.
使用cURL对 http://www.spicetvbox.ro/user/xbmc
进行HTTP POST-类似这样:
Use cURL to do an HTTP POST to http://www.spicetvbox.ro/user/xbmc
- something like this:
curl -b cookie.txt --data "run=UPDATEIP&id=89942" http://www.spicetvbox.ro/user/xbmc
此数据来自表单字段的值,URL来自表单元素的 action
属性.当指定-data
(等同于 -d
)时,cURL执行POST.
This data is taken from the value of the form fields and the URL is taken from the action
attribute of the form element. When --data
(equivalent to -d
) is specified, cURL performs a POST.
这篇关于使用curl&在网页上按javascript按钮;重击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!