title: Web-Scraping with LUA
body: <p>I am trying to build a web-scraper in Lua. It will act as an extension to the MoneyMoney App on OSX.</p>
  
  <p>Here is what I am doing to log into the site:</p>
  
  <pre><code>  local request = connection:request(loginPage:xpath("//*[@id='loginForm_submit']"):click())
    overview_html = HTML(request)
  </code></pre>
  
  <p>When authentication is successful, the ID of the HTML body will be "portfolio", otherwise it will be "login" (for a new attempt).</p>
  
  <p>I am trying to evaluate this as follows</p>
  
  <pre><code>  local login = overview_html:xpath("//*[@id='login']")
    if login.length() &gt; 0 then
      return LoginFailed
    end
  </code></pre>
  
  <p>But I get the following error when executing:</p>
  
  <blockquote>
    <p>kiva-extension.lua:42: bad argument #1 to 'length' (table expected,
    got no value)</p>
  </blockquote>
  
  <p>Line 42 is the "login.length > 0" check.</p>
  
  <p>As I am very new to both LUA and XPATH any help would be appreciated. Thanks!</p>