Remote server (403) Forbidden error while using WebClient

六月ゝ 毕业季﹏ 提交于 2019-11-29 15:05:37

If everything you said is correct, then I suspect server throttling is playing a part. Try adding a Thread.Sleep in your loop to slow things down.

Some web servers can block requests based on the user agent string they provide. In your case, you send an empty string as a user agent. Try to add the user agent of a browser, any browser would be fine.

For example:

client.Headers.Add("user-agent", " Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0");

For a list of user agents, you can click here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!