0
我想用c#在majestic.com上登录,但它运行不正常,它给出错误http 403。当我尝试访问安全(授权页)。这里是我的代码 任何帮助将非常Appreciated.here是我的代码如何使用c#登录majestic.com从其他雄伟的页面抓取数据
string formUrl = "https://majestic.com/account/login";
string formParams = string.Format("EmailAddress={0}&Password={1}", "[email protected]", "123456");
string cookieHeader;
WebRequest req = WebRequest.Create(formUrl);
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(formParams); req.ContentLength = bytes.Length;
using (Stream os = req.GetRequestStream()) { os.Write(bytes, 0, bytes.Length);
}
WebResponse resp = req.GetResponse();
cookieHeader = resp.Headers["Set-cookie"];
string pageSource;
string getUrl = "https://majestic.com/reports/site-explorer?q=daraz.pk&oq=sabzi.pk&IndexDataSource=F";
// here its give the error
WebRequest getRequest = WebRequest.Create(getUrl); getRequest.Headers.Add("Cookie", cookieHeader);
WebResponse getResponse = getRequest.GetResponse();
using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))