Изменение UserAgent в WebBrowser
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[System.Runtime.InteropServices.DllImport("urlmon.dll", CharSet = System.Runtime.InteropServices.CharSet.Ansi)] private static extern int UrlMkSetSessionOption( int dwOption, string pBuffer, int dwBufferLength, int dwReserved); const int URLMON_OPTION_USERAGENT = 0x10000001; const int URLMON_OPTION_USERAGENT_REFRESH = 0x10000002; public void ChangeUserAgent() { string ua = "Googlebot/2.1 (+http://www.google.com/bot.html)"; UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, null, 0, 0); UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, ua, ua.Length, 0); } |