HttpWebRequest
// 유동닉
private void button3_Click(object sender, EventArgs e)
{
string url = "http://m.dcinside.com/_option_write.php";
StringBuilder dataParams = new StringBuilder();
dataParams.Append("comment_nick=닉네임");
dataParams.Append("&comment_pw=암호");
dataParams.Append("&comment_memo=내용");
dataParams.Append("&mode=comment_nonmember");
dataParams.Append("&voice_file=");
dataParams.Append("&ukey=");
dataParams.Append("&di_code=");
dataParams.Append("&no=글번호");
dataParams.Append("&id=게시판이름");
dataParams.Append("&board_id=");
dataParams.Append("&user_no=");
byte[] byteDataParams = UTF8Encoding.UTF8.GetBytes(dataParams.ToString());
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
WebHeaderCollection myWebHeaderCollection = request.Headers;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
request.ContentLength = byteDataParams.Length;
request.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25";
//myWebHeaderCollection.Add("X-Requested-With", "XMLHttpRequest");
//myWebHeaderCollection.Add("Accept-Encoding", "gzip, deflate");
//myWebHeaderCollection.Add("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
request.Headers["X-Requested-With"] = "XMLHttpRequest";
request.Referer = "http://m.dcinside.com/list.php?id=";
request.Headers["Accept-Encoding"] = "gzip, deflate";
request.Headers["Accept-Language"] = "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4";
Stream stDataParams = request.GetRequestStream();
stDataParams.Write(byteDataParams, 0, byteDataParams.Length);
stDataParams.Close();
// 요청, 응답 받기
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
// 응답 Stream 읽기
Stream stReadData = response.GetResponseStream();
StreamReader srReadData = new StreamReader(stReadData, Encoding.Default);
// 응답 Stream -> 응답 String 변환
string strResult = srReadData.ReadToEnd();
MessageBox.Show(strResult);
//Console.WriteLine(strResult);
//Console.ReadLine();
}
Winhttp
public void comment(string no) // 댓글작성 메소드
{
WinHttpRequest Winhttp = new WinHttpRequest();
Winhttp.Open("POST", "http://m.dcinside.com/_option_write.php");
Winhttp.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
Winhttp.SetRequestHeader("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25");
Winhttp.SetRequestHeader("Referer", "http://m.dcinside.com/list.php?id=" + textBox4.Text);
Winhttp.SetRequestHeader("X-Requested-With", "XMLHttpRequest");
Winhttp.SetRequestHeader("Accept-Encoding", "gzip, deflate");
Winhttp.SetRequestHeader("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
Winhttp.Send("comment_nick=" + textBox1.Text + "&comment_pw=" + textBox2.Text + "&comment_memo=" + textBox3.Text + "&mode=comment_nonmember&voice_file=&ukey=&di_code=&no=" + no + "&id=" + textBox4.Text + "&board_id=&user_no=");
}
'Coding > Etc' 카테고리의 다른 글
C# Json 설치 (0) | 2015.11.18 |
---|---|
Multipart (0) | 2015.11.18 |
Regex 그룹명 붙이기 (0) | 2015.11.17 |
Webbrowser 에서 Proxy 설정하기 (0) | 2015.11.13 |
C# Webbrowser 자바스크립트 에러 disable (0) | 2015.11.13 |