Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public interface IHtmlDownloader
  2. {
  3. IWebProxy Proxy { get; set; }
  4. string UserAgent { get; set; }
  5.  
  6. string GetHtml(string url)
  7. }
  8.  
  9. public class HtmlDownloader : IHtmlDownloader
  10. {
  11. WebClient _client;
  12.  
  13. public IWebProxy Proxy
  14. {
  15. get { return _client.Proxy; }
  16. set { _client.Proxy = value; }
  17. }
  18.  
  19. public string UserAgent
  20. {
  21. get
  22. { return _client.Headers[HttpRequestHeader.UserAgent].ToString(); }
  23. set
  24. { _client.Headers[HttpRequestHeader.UserAgent] = value; }
  25. }
  26.  
  27. public HtmlDownloder()
  28. {
  29. _client = new WebClient();
  30. }
  31.  
  32. public string GetHtml(string url)
  33. {
  34. this.CheckValidity(url);
  35.  
  36. var htmlOfWebsite = _client.DownloadString(url);
  37.  
  38. return htmlOfWebsite;
  39. }
  40. }
  41.  
  42. { url = { required = true
  43. , dataType = ValidationTypes::URL }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement