2011-10-31 6 views
0

私はソケット、httpConnection、httpClient、プロキシ、クッキーなどを使用してたくさん試しましたが、これはちょっと失敗しています。私のプログラムが必要ですする必要がありますhtmlサイトにいくつかのデータを送信し、適切なresponse.But resposneをrecive私はexpection.Toの詳細は、私は少し具体的なサイトであると言っているの正確な反対ですhttp://hidemyass.comと私はフィールドの値を設定する必要がありますhttp ://reddit.com "whosの名前は、あなたはボタンを押して、魔法使いはRedditにプロキシ経由でリダイレクトされます。理論的に私はRedditのhtmlソースまたは正規のサーバレスポンスを得るべきです。しかし、私が得続けるのはhttp://hidemyass.com htmlですデフォルト値が設定されたソースコード(別名では、接続を介してそれらの値を送信しなかったため)。httpフィールド/フォームへのJavaの投稿は失敗し続けます

これは私がやったことであり、うまくいきませんでした。

CODE:

//I will skip used import because I think they are not of importance 
//Also try catch blocks will be skipped and not written 

private static UrlEncodedFormEntity entity; 

public static void main(String[] args){ 

    HttpClient client=new DefaultHttpClient(); 
    ArrayList<BasicNameValuePair> params=new ArrayList<BasicNameValuePair>(); 
    params.add(new BasicNameValuePair("u","http://reddit.com"); 
    params.add(new BasicNameValuePair("hmabutton,"Hide My Ass"); 
    entity=new UrlEncodedFormEntity(params,null)//there is no encoding on this site 
    HttpPost post=new HttpPost("http://hidemyass.com"); 
    post.setEntity(entity); 
    HttpResponse response=client.execute(post); 
    HttpEntity ent=response.getEntity(); 
    System.out.println(EntityUtils.toString(ent)); 
} 

誰も私が最終的に私のエラーを見て、私はやりたいようにサイトを得るのを助けることはできますか?

+0

[JavaではHTTPのPOSTリクエストを送信する]の可能な重複(http://stackoverflow.com/questions/3324717/sending-http-post -request-in-java) –

+1

「私がしたいことをするためのサイトを手に入れよう」 – javamonkey79

答えて

0

あなたは、フォームのアクションURLへのリクエストを投稿する必要があります。

HttpPost post=new HttpPost("http://hidemyass.com/process.php"); 
関連する問題