title: Web Scraping with c# and HTMLAgilityPack
body: <p><a href="https://i.stack.imgur.com/wSfdJ.png" rel="nofollow noreferrer">Screenshot of the code and error message+variable values</a> So, the goal is to  take a word and get the part of speech of the word from its google definition. </p>
  
  <p>I've tried a few different approaches but I'm getting a null reference error every time. Is my code failing to access the webpage? Is it a firewall issue, a logic issue, an {insert-issue-here} problem? I really wish i had a vague idea of what is wrong.</p>
  
  <p>Thanks for your time. </p>
  
  <p>Addendum: I've tried  "<strong>//<em>[@id=\"source - luna\"]//div</strong>"   and   "<strong>//</em>[@id=\"source - luna\"]/div<a href="https://i.stack.imgur.com/wSfdJ.png" rel="nofollow noreferrer">1</a></strong>" as XPath values.
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>//attempt 1////////////////////////////////////////////////////////////////////////
              var term = "Hello";
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.urbandictionary.com/define.php?term=" + term);
              HttpWebResponse response = (HttpWebResponse)request.GetResponse();
  
              StreamReader stream = new StreamReader(response.GetResponseStream());
              string final_response = stream.ReadToEnd();
  
              MessageBox.Show(final_response); //doesn't execute
  
  //attempt 2////////////////////////////////////////////////////////////////////////
              var url = "https://www.google.co.za/search?q=define+position";
              var content = new System.Net.WebClient().DownloadString(url);
              var webGet = new HtmlWeb();
              var doc = new HtmlAgilityPack.HtmlDocument();
              doc.LoadHtml(content);
       //doc is null at runtime
              HtmlNode ourNode = doc.DocumentNode.SelectSingleNode("//*[@id=\"uid_0\"]/div[1]/div/div[1]/div[2]/div[2]/div[1]/i/span");
              if (ourNode != null)
              {
                  richTextBox1.AppendText(ourNode.InnerText);
              }
              else
                  richTextBox1.AppendText("null");
  
  //attempt 3////////////////////////////////////////////////////////////////////////
  var webGet = new HtmlWeb();
              var doc = webGet.Load("https://www.google.co.za/search?q=define+position");
       //doc is null at runtime
              HtmlNode ourNode = doc.DocumentNode.SelectSingleNode("//*[@id=\"uid_0\"]/div[1]/div/div[1]/div[2]/div[2]/div[1]/i/span");
              if (ourNode != null)
              {
                  richTextBox1.AppendText(ourNode.InnerText);
              }
              else
                  richTextBox1.AppendText("null");
  
  //attempt 4////////////////////////////////////////////////////////////////////////
  string Url = "http://www.metacritic.com/game/pc/halo-spartan-assault";
              HtmlWeb web = new HtmlWeb();
              HtmlAgilityPack.HtmlDocument doc = web.Load(Url);
       //doc is null at runtime
              string metascore = doc.DocumentNode.SelectNodes("//*[@id=\"main\"]/div[3]/div/div[2]/div[1]/div[1]/div/div/div[2]/a/span[1]")[0].InnerText;
              string userscore = doc.DocumentNode.SelectNodes("//*[@id=\"main\"]/div[3]/div/div[2]/div[1]/div[2]/div[1]/div/div[2]/a/span[1]")[0].InnerText;
              string summary = doc.DocumentNode.SelectNodes("//*[@id=\"main\"]/div[3]/div/div[2]/div[2]/div[1]/ul/li/span[2]/span/span[1]")[0].InnerText;
              richTextBox1.AppendText(metascore + " " + userscore + " " + summary);
  
  //attempt 5////////////////////////////////////////////////////////////////////////
               HtmlWeb web = new HtmlWeb();
               HtmlAgilityPack.HtmlDocument html = web.Load("https://www.google.co.za/search?q=define+position");
       //html is null
               var div = html.DocumentNode.SelectNodes("//*[@id=\"uid_0\"]/div[1]/div/div[1]/div[2]/div[2]/div[1]/i/span");
               richTextBox1.AppendText(Convert.ToString(div));</code></pre>
  </div>
  </div>
  </p>