Page 1 of 1

trouble autosubmitting form with curl

Posted: Wed Jun 15, 2011 9:38 pm
by kc11
Hi everyone,

I am having trouble filling out and submitting a form using CURL.

Here is the form:

[text]

</p><form action=""includes/process.php?action=update"" method="post">
<p style="text-align: center;">
<input style="width: 400px;" name="u" id="input" class="urlinput" size="40" type="text">
<input value="&nbsp;&nbsp;&nbsp;Go&nbsp;&nbsp;&nbsp;" class="submitbutton" type="submit">
<br>
<input name="encodeURL" id="encodeURL" checked="checked" type="checkbox">
<label for="encodeURL" class="tooltip" title="Encode URL::Encodes the URL of the page you are viewing so that it does not contain the target site in plaintext.">Encode URL</label> <input name="encodePage" id="encodePage" type="checkbox">
<label for="encodePage" class="tooltip" title="Encode Page::Helps avoid filters by encoding the page before sending it and decoding it with javascript once received. This is not 100% reliable and may break functionality in some browsers.">Encode Page</label> <input name="allowCookies" id="allowCookies" checked="checked" type="checkbox">
<label for="allowCookies" class="tooltip" title="Allow Cookies::Cookies may be required on interactive websites (especially where you need to log in) but advertisers also use cookies to track your browsing habits.">Allow Cookies</label> <input name="stripJS" id="stripJS" type="checkbox">
<label for="stripJS" class="tooltip" title="Remove Scripts::Remove scripts to protect your anonymity and speed up page loads. However, not all sites will provide an HTML-only alternative. (Recommended)">Remove Scripts</label> <input name="stripObjects" id="stripObjects" type="checkbox">
<label for="stripObjects" class="tooltip" title="Remove Objects::You can increase page load times by removing unnecessary Flash, Java and other objects. If not removed, these may also compromise your anonymity.">Remove Objects</label>
<br><br>

[/text]

Here is my CURL code

Code: Select all



  $ch = curl_init();
  $timeout = 105;
  curl_setopt($ch,CURLOPT_URL,$url);
   curl_setopt($ch, CURLOPT_VERBOSE, 1);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch,CURLOPT_POST,1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, 'u=www.yahoo.com&encodeURL=on&allowCookies=on');
curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);   // Cookie management.
	curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);
	curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1');
		curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate'); 
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
  
  
		
 
  $data = curl_exec($ch);
  curl_close($ch);
  return $data;



The form does not seem to be submitted, by curl - The output from $data only returns the original webpage. Can anyone help?

Thanks in advance,

KC

Re: trouble autosubmitting form with curl

Posted: Wed Jun 15, 2011 11:14 pm
by twinedev
can you give the value of $url? (replace actual domain with domain.com if you want to keep the real one not known)

Re: trouble autosubmitting form with curl

Posted: Thu Jun 16, 2011 7:09 am
by kc11
Sorry ,

$url = "fewadsproxy.info";

Thanks for looking at it,

KC

Re: trouble autosubmitting form with curl

Posted: Thu Jun 16, 2011 12:05 pm
by twinedev
Remember that curl browses to the page similar to if you do it in a browser, so this means you are just calling the home page.

You need to grab the action in for <form> tag (and add it to the root site):

Code: Select all

$url = 'http://fewadsproxy.info/includes/process.php?action=update";
Try that and see if it works.

-Greg

Re: trouble autosubmitting form with curl

Posted: Thu Jun 16, 2011 10:11 pm
by kc11
Hi Greg,

That is definitely a much closer. The form does now appear to be submitted, by curl - The output from $data now looks like the top of the page when I submit the page by hand. Here are the contents of $data:

[text]

<script type="text/javascript">ginf={url:'http://fewadsproxy.info',script:'browse.php',target:{h:'http://www.yahoo.com',p:'/',b:''},enc:{u:'',e:'1',p:''},b:'5'}</script>
<script type="text/javascript" src="http://fewadsproxy.info/includes/main.js"></script>
<div style="padding:4px;margin-bottom:2px;background:#eee;font:12px Verdana,Arial,Tahoma;color:#000;">
<form action="includes/process.php?action=update" method="post" style="padding:0;margin:0;">
<b>URL:</b> <input type="text" name="u" size="40" value="http://www.yahoo.com" style="width:400px;border: 1px solid #447900;">
<input type="submit" value="Go">
[<a href="index.php">home</a>] [<a href="includes/process.php?action=cookies&type=all&return=browse.php%3Fu%3DOi8vd3d3LnlhaG9vLmNvbQ%253D%253D%26b%3D5%26f%3Dnorefer">clear cookies</a>]
<br>

<b>Options:</b>

<input type="checkbox" name="encodeURL" id="encodeURL" checked="checked" >
<label for="encodeURL" style="display:inline;">Encode URL</label> <input type="checkbox" name="encodePage" id="encodePage">
<label for="encodePage" style="display:inline;">Encode Page</label> <input type="checkbox" name="allowCookies" id="allowCookies" checked="checked" >
<label for="allowCookies" style="display:inline;">Allow Cookies</label> <input type="checkbox" name="stripJS" id="stripJS">

<label for="stripJS" style="display:inline;">Remove Scripts</label> <input type="checkbox" name="stripObjects" id="stripObjects">
<label for="stripObjects" style="display:inline;">Remove Objects</label>
</form>

</div><!-- w32.fp.ac4.yahoo.com uncompressed/chunked Thu Jun 16 18:32:51 PDT 2011 -->





[/text]




The output cuts off after 1637 characters. Notice that the last line refers to yahoo.com which should also be returned, but isn't. Any idea why?

Thank you again,

KC

Re: trouble autosubmitting form with curl

Posted: Thu Jun 16, 2011 10:45 pm
by Jonah Bron
How much more should there be?

Re: trouble autosubmitting form with curl

Posted: Fri Jun 17, 2011 8:04 am
by kc11
Thanks for replying Jonah,

The site I am using curl with is a proxy site, so manually when I fill out the form with "yahoo.com" It will return the form just as I showed above ,followed by the requested page ( in this case the "yahoo.com" homepage). I have the form returned at the top , but not the yahoo.com webpage

KC

Re: trouble autosubmitting form with curl

Posted: Fri Jun 17, 2011 9:19 pm
by kc11
Interestingly, it may be working after all. when I set the postfield argument 'u' to www.google.com or www.news.yahoo.com, the entire page is displayed correctly.