开发者

How to use webbrowsr control with Httpwebrequest?

I am开发者_如何学运维 using webbrowser control , and i get list of all the url of all the profiles from the search result.

After this is there any way that i use httpwebrequest to get the data from the urls?

I wanted to use the Linked in search profile api but that is very confusing. Also i tried using httpwebrequest but it takes me to the linkedin login page.

I was thinking of any way that as i signed in to linkedin using the webbrowser control maybe using that information of webbrowser and adding with my request to pretend to be logged in .

Any ideas? Please help


The HttpWebRequest sent you to the login page, because there isn´t the cookie with the validation. So, you'll can connect using WebBrowser control and get the cookie, then put the cookie in the webrequest

        webBrowser.Navigate(someUrl);

        ...

        CookieContainer cookies = new CookieContainer();
        foreach (string cookie in webBrowser.Document.Cookie.Split(';'))
        {
            string name = cookie.Split('=')[0];
            string value = cookie.Substring(name.Length + 1);
            string path = "/";
            string domain = "yourdomain.com";
            cookies.Add(new Cookie(name.Trim(), value.Trim(), path, domain));
        }


        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.CookieContainer = cookies;
        ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜