Faking browser request in ASP.net C#

后端 未结 4 1136
自闭症患者
自闭症患者 2020-12-15 12:14

I\'m using the code below to pull one of our 3rd party developed pages in so I can parse it as XML for my random bits of work.

Irritatingly we stil have a browser de

4条回答
  •  太阳男子
    2020-12-15 12:42

    as with Waldens above but had to replace

    objRequest.UserAgent = 
       "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)";
    

    with

    ((System.Net.HttpWebRequest)objRequest).UserAgent = "Mozilla/5.0 (compatible; Googlebot/2.1; http://www.google.com/bot.html)";
    

    Otherwise it fell over. (I changed the browser to googlebot to evade our cookie server)

提交回复
热议问题