title: Scraping a Facebook App for Data
body: <p>I'm using a Facebook application that has a rich set of information that I'd like to get at offline. To do this, I essentially need to read the infromation from the web pages into my own database. Obviously, I'd prefer not to have to save pages manually and let my application read the pages and pull the relevant details from them. Unfortunately, I am road-blocked by the requirement to authenticate to Facebook first. So when I run this code:</p>
  
  <pre><code>private static string getPage(string pageAddress)
  {
      HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new Uri(baseUri, pageAddress));
      HttpWebResponse response = (HttpWebResponse)req.GetResponse();
      StreamReader readStream = new StreamReader(response.GetResponseStream());
      string page = readStream.ReadToEnd();
      readStream.Close();
      response.Close(); // I know, I'm paranoid and this is likely redundant...
      return page;
  }
  </code></pre>
  
  <p>I get this response:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  if (parent != self) 
  top.location.href = "http://www.facebook.com/login.php?api_key=&lt;obscured&gt;&amp;canvas&amp;v=1.0";
  else self.location.href = "http://www.facebook.com/login.php?api_key=&lt;obscured&gt;&amp;canvas&amp;v=1.0";
  &lt;/script&gt;
  </code></pre>
  
  <p>Any ideas how to tell the app that I really <em>am</em> the authentic me?</p>