Created
September 3, 2016 14:19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
namespace InstPost | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private string GET(string Url, string Data) | |
{ | |
WebRequest req = WebRequest.Create(Url + "?" + Data); | |
WebResponse resp = req.GetResponse(); | |
Stream stream = resp.GetResponseStream(); | |
StreamReader sr = new StreamReader(stream); | |
MessageBox.Show(resp.Headers[HttpResponseHeader.SetCookie]); | |
string Out = sr.ReadToEnd(); | |
sr.Close(); | |
return Out; | |
} | |
private string POST(string Url, string Data) | |
{ | |
WebRequest req = WebRequest.Create(Url); | |
req.Method = "POST"; | |
req.Timeout = 100000; | |
req.ContentType = "application/x-www-form-urlencoded"; | |
byte[] sentData = Encoding.GetEncoding(1251).GetBytes(Data); | |
req.ContentLength = sentData.Length; | |
Stream sendStream = req.GetRequestStream(); | |
sendStream.Write(sentData, 0, sentData.Length); | |
sendStream.Close(); | |
WebResponse res = req.GetResponse(); | |
Stream ReceiveStream = res.GetResponseStream(); | |
StreamReader sr = new StreamReader(ReceiveStream, Encoding.UTF8); | |
//Кодировка указывается в зависимости от кодировки ответа сервера | |
Char[] read = new Char[256]; | |
int count = sr.Read(read, 0, 256); | |
string Out = String.Empty; | |
while (count < 0) | |
{ | |
String str = new String(read, 0, count); | |
Out += str; | |
count = sr.Read(read, 0, 256); | |
} | |
return Out; | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
GET("https://www.instagram.com", String.Empty); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment