title: UPS: AWB tracking via web crawling
body: <h2>Problem</h2>
  
  <p>Here at work, people spend a lot of time tracking AWB (Air way bill) from diferent sources (UPS, FedEx, DHL, ...). So, I was required to improve the process in order save valuable time, I was thinking to accomplish this using Excel as platform with Excel-DNA &amp; C# but I have been trying some tests (crawling UPS) with no success.</p>
  
  <h2>Tests</h2>
  
  <pre><code>HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://wwwapps.ups.com/WebTracking/track?HTMLVersion=5.0&amp;loc=es_MX&amp;Requester=UPSHome&amp;WBPM_lid=homepage%2Fct1.html_pnl_trk&amp;trackNums=5007052424&amp;track.x=Rastrear");
  
  request.Method = "GET";
  request.UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36";
  request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  request.Headers.Add("Accept-Language: es-ES,es;q=0.8");
  request.Headers.Add("Accept-Encoding: gzip,deflate,sdch");
  request.KeepAlive = false;
  request.Referer = @"http://www.ups.com/";
  request.ContentType = "text/html; charset=utf-8";
  
  HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  StreamReader sr = new StreamReader(response.GetResponseStream());
  </code></pre>
  
  <h3>Or...</h3>
  
  <pre><code>using (var client = new WebClient())
  {
      var values = new NameValueCollection();
  
      values.Add("HTMLVersion", "5.0");
      values.Add("loc", "es_MX");
      values.Add("Requester", "UPSHome");
      values.Add("WBPM_lid", "homepage/ct1.html_pnl_trk");
      values.Add("trackNums", "5007052424");
      values.Add("track.x", "Rastrear");
  
      client.Headers[HttpRequestHeader.Accept] = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
      client.Headers[HttpRequestHeader.AcceptEncoding] = "gzip,deflate,sdch";
      client.Headers[HttpRequestHeader.AcceptLanguage] = "es-ES,es;q=0.8";
      client.Headers[HttpRequestHeader.Referer] = @"http://www.ups.com/";
      client.Headers[HttpRequestHeader.UserAgent] = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36";
  
      string url = @"https://wwwapps.ups.com/WebTracking/track?";
      byte[] result = client.UploadValues(url, values);
  
      System.IO.File.WriteAllText(@"C:\UPSText.txt", Encoding.UTF8.GetString(result));
  }
  </code></pre>
  
  <p>But none of the above examples worked as expected.</p>
  
  <h2>Question</h2>
  
  <p>Is it possible to web-crawl UPS in order to keep a track of AWB?</p>
  
  <h2>Note</h2>
  
  <p>Currently, I have no access to UPS API.</p>