Actually, I'm programming a windows store application, I try to parse a website, but the response return that it has an error in the request is not required. I have a snapshot that maybe help us to find a solution this code worked with all website I tried, but there is not working.
I use this sourcecode :
private async void parsingActualites()
{
HttpClient http = new System.Net.Http.HttpClient();
HttpClientHandler newClientHandler = new HttpClientHandler();
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
***var reponse = await http.GetByteArrayAsync("http://.........../");***
str3 = Encoding.UTF8.GetString(reponse, 0, reponse.Length - 1);
var strdecodet = System.Net.WebUtility.HtmlDecode(str3);
HtmlAgilityPack.HtmlDocument document2 = new HtmlAgilityPack.HtmlDocument();
document2.LoadHtml(str3);
the error that showed to me is :
Response status code does not indicate success: 403 (Forbidden).
Res
this is a picture to describe more the error please can you help me :)
There could be several reasons for what you are experiencing. For example - the site may require authentication which your program does not perform but you did manually while browsing. Or the website is expecting headers which your program does not provide.
The right way to solve this issue is to understand what the browser does and you don't. Download Fiddler, run it and then browse to the url. Fiddler will display the actual requests made by your browser. Here's an example - .
As you can see, the browser sends several more headers you should do the same (actually you should find the minimal set that works). To add headers - take a look at http://massivescale.com/pages/custom-headers-with-httpclient/ or How do you set the Content-Type header for an HttpClient request?