壳牌:连接到一个网站和访问字段 [英] Shell: Connecting to a website and accessing a field

查看:118
本文介绍了壳牌:连接到一个网站和访问字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个脚本,需要一个参数,它是文本,打开使用字段的ID到一个特定的网站,并输入ARG连接到文本字段。这可能吗?我会怎么做呢?我是一个总的外壳小白

编辑:

精确流量:

   - 开始用绳子脚本
- 输入字符串文本字段的网页上
- 点击表单按钮
- 等待处理
- 点击超链接


解决方案

为让您一开始,这里是我的脚本,从我们当地的食堂订购今天的午餐:

  URL =htt​​ps://lunch.com/lunch/cgi-bin/order.cgiO =order =序列
A =amount_%D = %% D&放大器; amount_foil_container_%D = %% D功能order_lunch(){
  如果[-n$ @]];然后
    卷曲-u$ USER:$ PASSWORD\\
         -d $($的printf(printf的$的O& $ A和$ A和$ A和$ A0 0 1 1 2 2 3 3)\\
                     $ {@:2:8})\\
         $网址;
  其他
    回声没有订购。
  网络连接;
}

在哪里输入是在以下格式的字符串

  2012年8月23日1 0 0 0 0 0 0 0

其中每个字段表示不同的菜,即在日期后的第一个位置的1是1面食

祝你好运。

I want to write a script that takes an argument which is text, opens a connection to a specific website and input the arg into text field using the field's ID. Is this possible? How would I do this? I'm a total shell noob

Edit:

Exact flow:

- start script with string
- input string into text field on web page
- click form button
- wait for processing
- click hyperlink

解决方案

To get you started, here is my script to order today's lunch from our local canteen:

URL="https://lunch.com/lunch/cgi-bin/order.cgi"

O="order=Order"
A="amount_%d=%%d&amount_foil_container_%d=%%d"

function order_lunch() {
  if [[ -n "$@" ]]; then
    curl -u "$USER":"$PASSWORD" \
         -d $(printf $(printf "$O&$A&$A&$A&$A" 0 0 1 1 2 2 3 3) \
                     "${@:2:8}") \
         "$URL";
  else
    echo "Nothing to order.";
  fi;
}

Where input is a string in the following format

2012-08-23 1 0 0 0 0 0 0 0

where each field denotes a different dish, i.e. a 1 in the first position after the date is "1 pasta"

Good luck.

这篇关于壳牌:连接到一个网站和访问字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆