curl-users
Re: curl-users Digest, Vol 82, Issue 22
Date: Wed, 27 Jun 2012 15:34:35 +0800
> Message: 5
> Date: Wed, 27 Jun 2012 09:55:02 +0800
> From: Alfred Zhang <alfredzhang83_at_gmail.com>
> To: curl-users_at_cool.haxx.se
> Subject: How to use curl to manipulate the web message?
> Message-ID:
> <CAHEoT5+fuokw0LOZWCAasbroq6VUAaEPmo22EsLHfRFkGw4OzQ_at_mail.gmail.com
> >
> Content-Type: text/plain; charset="gb2312"
>
> Dear friends,
>
> Good morning my frends, I am a fresh men for using curl , and I am very
> glad to join curl-user mailing list.
> I have a problem on how to post a form with "curl -d" , e.g. , asuming I
> want to use Google to search a
> key word "cat" , how can I use curl to make it?
>
> The following html code is excerpt from Goole main page for china (
> https://www.google.com.hk/).
>
>
> *<form action="/search" id="tsf" method="GET" onsubmit="return q.value!=''"
> role="search" name="f" style="display:block;background:none">
> <div id="tophf">
> <input type=hidden name=hl value="en">
> <input type=hidden name=newwindow value="1">
> <input type=hidden name=safe value="strict">
> <input type=hidden name=site value="">
> <input name="source" type="hidden" value="hp">
> </div>
> <div class="tsf-p" style="position:relative">
> <div class="nojsv" id="logocont"
> style="left:0;position:absolute;padding:">
> <h1>
> <a id=logo href="https://www.google.com.hk/webhp?hl=en" title="Go to
> Google Home">
> Google
> <img width=167 height=389 src="/images/nav_logo107.png" alt="">
> </a>
> </h1>
> </div>
> <div style="padding-bottom:2px;padding-top:1px">
> <table border="0" cellpadding="0" cellspacing="0" width="100%">
> <tr>
> <td width="100%">
> <table border="0" cellpadding="0" cellspacing="0" width="100%"
> style="position:relative;border-bottom:1px solid transparent">
> <tr>
> <td class="lst-td" id="sftab" width="100%" style="border:0">
> <div class="lst-d lst-tbb">
> <input class="lst lst-tbb" value="" title="Search" size="41"
> type="text" autocomplete="off" id="lst-ib" name="q" maxlength="2048">
> <span id="tsf-oq" style="display:none"></span>
> </div>
> </td>
> <td>
> <div class="nojsb">
> <div class="ds" id="sbds">
> <div class="lsbb kpbb" id="sblsbb">
> <button class="lsb" value="Search" type="submit" name="btnG">
> <span class="sbico"></span>
> </button>
> </div>
> </div>
> </div>
> </td>
> </tr>
> </table>
> </td>
> <td>
> <div class="nojsv" id="sfopt"
> style="height:30px;position:relative">
> <div class="lsd"> </div>
> </div>
> </td>
> </tr>
> <tr>
> <td>
> <div id="pocs" style="display:none">
> <div id="pocs0">
> <span>
> <span>Google</span>
> Instant is unavailable. Press Enter to search.
> </span>
> <a
>
> href="/support/websearch/bin/answer.py?answer=186645&form=bb&hl=en">Learn
> more</a>
> </div>
> <div id="pocs1">
> <span>Google</span>
> Instant is off due to connection speed. Press Enter to search.
> </div>
> <div id="pocs2">
> Press Enter to search.
> </div>
> </div>
> <div id="pets"
> style="color:#767676;display:none;font-size:9pt;margin:5px 0 0 8px">
> Press Enter to search.
> </div>
> </td>
> </tr>
> </table>
> </div>
> <div class="jsb" style="padding-top:2px">
> <center>
> <input value="Google Search" name="btnK" type="submit"
> onclick="this.checked=1" />
> <input value="I'm Feeling Lucky" name="btnI" type="submit"
> onclick="if(this.form.q.value)this.checked=1; else
> top.location='/doodles/'" />
> </center>
> </div>
> </div>
> </form> *
>
> Give me a hand , please !
>
>
> Alfred Zhang , Shanghai ,China.
>
> --
> ??????????????
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://cool.haxx.se/pipermail/curl-users/attachments/20120627/b3bb5cf1/attachment.html
> >
>
> ------------------------------
>
> _______________________________________________
> curl-users mailing list
> curl-users_at_cool.haxx.se
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
>
>
> End of curl-users Digest, Vol 82, Issue 22
> ******************************************
>
From: Weedy <weedy2887_at_gmail.com<weedy2887_at_gmail.com?Subject=Re:%20How%20to%20use%20curl%20to%20manipulate%20the%20web%20message?>>
Date: Wed, 27 Jun 2012 00:55:30 -0400
On 26/06/12 09:55 PM, Alfred Zhang wrote:
*> Dear friends, *
*> *
*> Good morning my frends, I am a fresh men for using curl , and I am very *
*> glad to join curl-user mailing list. *
*> I have a problem on how to post a form with "curl -d" , e.g. , asuming *
*> I want to use Google to search a *
*> key word "cat" , how can I use curl to make it? *
If all you want to do is get search results you only need URL encode the
"q" parameter. That said doing anything automated with google probably
violated there TOS
https://www.google.ca/search?q=cat&hl=en&num=10&lr=lang_en
Dear Weedy ,
Thanks for your great help, this method is very useful to me .
Acturely , my question is from this articule :
http://curl.haxx.se/docs/httpscripting.html
In this articule , the section 4.2 said :
......
* The form would look very similar to the previous one:
<form method="POST" action="junk.cgi">
<input type=text name="birthyear">
<input type=submit name=press value=" OK ">
</form>
And to use curl to post this form with the same data filled in as before, we
could do it like:
curl --data "birthyear=1905&press=%20OK%20"
http://www.example.com/when.cgi
......
*
So, I think that if the html element "*<input type=submit name=press
value=" OK ">* " does not contain an "*name*" attribute, like
*<input type=submit value=" OK ">
*thus, what should the curl command be ? Maybe like the following command ?
*curl --data "birthyear=1905" http://www.example.com/when.cgi*
Dose this right?
*Best Reguards to you !
Have a nice day !*
Alfred Zhang,
Shanghai, China
-- 我以为看到了曙光。。。。。。
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-06-27