0

I am trying to access http://www.b-maison-a-louer/rouyn-noranda/c43l1700060 however, kijiji is forcing a default location which requires user to manually set the city before allowing access to that url, I have below code that I am trying but it doesnt seem to work for the content, however it does switch it from french to english. I am not sure what other cookie I should be setting that would please kijiji to allow me to access a url directly.

public static string GetHTML(string url)
    {

        var client = new WebClient { Encoding = Encoding.UTF8 };

        client.Headers.Add(HttpRequestHeader.Cookie, "site_preference=Vignore_out_of_country=enabled^default_area=1700060, siteLocale=en_CA, ");
        return client.DownloadString(url);

    }
Zoinky
  • 4,083
  • 11
  • 40
  • 78

1 Answers1

0

One way to find out :

1 clear all of your browser's temperate file/cookies

2 turn on developer tools, capture internet traffic

3 go on kijiji and see which cookie is it setting

4 do the same in your webclient

Some times you also need to add some certain headers to do the trick

Steve
  • 11,696
  • 7
  • 43
  • 81
  • I have, the one that gets set is site_preference which I set but doestn seem to make any difference – Zoinky Jan 30 '14 at 20:11
  • @Zoinky you only added cookie headers, make sure you add in other headers that appears in your browser's internet traffic too. from what i know some sites expects that you send the user-agent header before the server would do anything – Steve Jan 31 '14 at 14:00