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()))