Shell: Connecting to a website and accessing a field

后端 未结 4 1380
面向向阳花
面向向阳花 2021-01-03 02:39

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 poss

4条回答
  •  误落风尘
    2021-01-03 03:01

    think you need to get to grips with forms first before attempting this.

    Meaning you could reproduce thml file locally which includes all the values of the form, the forms action could be the end url steps 3 and 4, also look into auto submit java scripts

    The final hyperlink well once the form is submitted - if the last step by parsing outcome of the post and then using curl or wget or something that would act as the click

    E2A the problem with a bash script is my concept above of creating the form is bull crap since to then execute a java script command line browser or links/lynx/wget/curl etc will be a challenge.

    tne first question is does the form support both get and post - if form action can only be post then you will not be able to send form fields as variables i.e.

    http://destinatio-form-url.com/acceptform.cgi?user=something&address=something_else

    This above exampe is how you coud generate your form values if get is supported if however you need to post then a form needs to be gnerated with form action set to post to get to that url and it goes like I said you need to create the form.

    If assuming you can send it via above format then the thing to watch for is where the response in the clickable link is if its another click away - you can see the problem if however it is returned on the same page submitted to then - it be pretty easy to parse the html by grepping for something specific and grepping/awking until you get exact url which you fire off,

    take a look at my answer here

    bash script to login to webpage

    This is how you would go about in java authenticating grabbing a cookie then progressing as a logged in user, the thing there is all you need to post your form

    All I am saying is it is possible in bash but for url processing maybe done in a better language which gives you all the libraries to do this and makes it elegant rather than calling all sorts of system commands

    The example given is in Java but could be in any language, perl,php,python and so forth and they should all have libraries for this task, for Perl look up LWP html in google and lots of specific libraries like LWP HTML Parser and so forth you could use

    Anyhow all the best

    I think links supports java scripts if it helps..

    it is like lynx but has a lot more addons

        apt-cache search links|grep browser
    amule-gnome-support - ed2k links handling support for GNOME web browsers
    elinks - advanced text-mode WWW browser
    elinks-data - advanced text-mode WWW browser - data files
    elinks-doc - advanced text-mode WWW browser - documentation
    elinks-lite - advanced text-mode WWW browser - lightweight version
    libhtmlunit-core-js-java - GUI-Less browser for Java programs - JavaScript engine
    libhtmlunit-java - GUI-Less browser for Java programs
    libjenkins-htmlunit-java - Jenkins branch of HtmlUnit browser testing for web apps
    libphp-snoopy - Snoopy is a PHP class that simulates a web browser
    links - Web browser running in text mode
    links2 - Web browser running in both graphics and text mode
    man2html - browse man pages in your web browser
    surf - simple web browser
    

提交回复
热议问题