Exemple #1
0
    public int ParseUrl(HTTPRequest page)
    {
      int count = 0;

      if (_page != page)
      {
        HTMLPage webPage = new HTMLPage(page);
        _source = webPage.GetPage();
        _page = new HTTPRequest(page);
      }

      JSONNode root = JSONNode.LoadJSON(_source);
      try
      {
        _nodeList = root.GetNodes(_data.XPath, _data.ChannelFilter);
      }
      catch (Exception) // ex)
      {
        //Log.Error("WebEPG: JSON failed");
        return count;
      }

      if (_nodeList != null)
      {
        count = _nodeList.Count;
      }

      return count;
    }
        /// <summary>
        /// Parses the URL and returns the number of instances of the template found on this site
        /// </summary>
        /// <param name="site">The site.</param>
        /// <returns>count</returns>
        public int ParseUrl(HTTPRequest site)
        {
            HTMLPage webPage    = new HTMLPage(site);
            string   pageSource = webPage.GetPage();

            int startIndex = 0;

            if (_template.Start != null && _template.Start != string.Empty)
            {
                startIndex = pageSource.IndexOf(_template.Start, 0, StringComparison.OrdinalIgnoreCase);
                if (startIndex == -1)
                {
                    startIndex = 0;
                }
                //log error ?
            }


            int endIndex = pageSource.Length;

            if (_template.End != null && _template.End != string.Empty)
            {
                endIndex = pageSource.IndexOf(_template.End, startIndex, StringComparison.OrdinalIgnoreCase);
                if (endIndex == -1)
                {
                    endIndex = pageSource.Length;
                }
                //log error?
            }

            int count = 0;

            if (pageSource != null)
            {
                count = _profiler.MatchCount(pageSource.Substring(startIndex, endIndex - startIndex));
            }

            return(count);
        }
Exemple #3
0
    public int ParseUrl(HTTPRequest page)
    {
      int count = 0;

      if (_page != page)
      {
        HTMLPage webPage = new HTMLPage(page);
        _source = webPage.GetPage();
        _page = new HTTPRequest(page);
      }

      XmlDocument _xmlDoc = new XmlDocument();
      try
      {
        _xmlDoc.LoadXml(_source);
        if (_data.Channel != string.Empty)
        {
          _nodeList =
            _xmlDoc.DocumentElement.SelectNodes(_data.XPath + "[@" + _data.Channel + "=\"" + _channelName + "\"]");
        }
        else
        {
          _nodeList = _xmlDoc.DocumentElement.SelectNodes(_data.XPath);
        }
      }
      catch (XmlException) // ex)
      {
        //Log.Error("WebEPG: XML failed");
        return count;
      }

      if (_nodeList != null)
      {
        count = _nodeList.Count;
      }

      return count;
    }
Exemple #4
0
    /// <summary>
    /// Parses the URL and returns the number of instances of the template found on this site
    /// </summary>
    /// <param name="site">The site.</param>
    /// <returns>count</returns>
    public int ParseUrl(HTTPRequest site)
    {
      HTMLPage webPage = new HTMLPage(site);
      string pageSource = webPage.GetPage();

      int startIndex = 0;
      if (_template.Start != null && _template.Start != string.Empty)
      {
        startIndex = pageSource.IndexOf(_template.Start, 0, StringComparison.OrdinalIgnoreCase);
        if (startIndex == -1)
        {
          startIndex = 0;
        }
        //log error ?
      }


      int endIndex = pageSource.Length;

      if (_template.End != null && _template.End != string.Empty)
      {
        endIndex = pageSource.IndexOf(_template.End, startIndex, StringComparison.OrdinalIgnoreCase);
        if (endIndex == -1)
        {
          endIndex = pageSource.Length;
        }
        //log error?
      }

      int count = 0;
      if (pageSource != null)
      {
          //run the replacement tasks before parsing the page source
          count = _profiler.MatchCount(Replacements(pageSource.Substring(startIndex, endIndex - startIndex)));
      }

      return count;
    }
Exemple #5
0
 public int ParseUrl(HTTPRequest site)
 {
   HTMLPage webPage = new HTMLPage(site);
   return _rows.RowCount(webPage.GetPage());
 }