Please login or register.

Login with username, password and session length

 

News:

Welcome to the Updated Lua Forum!


Author Topic: somebody expalin play on script (scrape function and other question lsted )  (Read 76 times)

ahsan

  • Newbie
  • Posts: 1
    • View Profile
can any one pls tell me what this function is doing?especially scrape_page
1)how does it split(cant understand what this means "#!#")
2)search keys
3)explain the syntax(_vf(ret_list.title, "Load_ZEETV_Shows|"..baseurl.."|"..ret_list.title);)

function Load_ZEETV_Menu()
   local baseurl = "http://www.zeetv.com/shows";
   
   local ret_list = Scrape_Page(baseurl, 2, "", "")
   
   for i = 1, table.getn(ret_list) do
      _vf(ret_list.title, "Load_ZEETV_Shows|"..baseurl.."|"..ret_list.title);
   end;
   
   Version_Check("ZEETV", HT_Script_Version);
end;

function Load_ZEETV_Shows(url, strCat)
   local s = GetURLCached(url, 2048);
   
   local ret_list = Scrape_Page("", 3, strCat, s);
   
   for i = 1, table.getn(ret_list) do
      _vf(ret_list.title, "Load_ZEETV_Pages|"..ret_list.vidurl);
   end;
   
end;
local function Scrape_Page(url, srch_type, srch_items, s, debug_on)
--Needs to be located before any call to this function
   
   local srch_param = {};
   if srch_items ~= "" then
      srch_param = str_split(srch_items, "#!#");
      for i = table.getn(srch_param) + 1, 5 do
         srch_param = "";
      end;
     else
      srch_param = {"","","","","",""};
   end;
   
   local srch_keys = {{   --1 Script Version
                     {name = "fstart", start = '<id>'..srch_param[1]..'</id>', startplain = true, lastending = "", required = true, pageend = '</scripts>', sel_end = "</script>", skip_end = "", anyorder = true, maxretries = 1, returnmaxrows = 1},
                     {name = "name", start = '<name>', lastending = '', ending = "</name", required = false, notfound = ""},
                     {name = "version", start = '<version>', lastending = '', ending = "</version", required = true, notfound = ""},
                     {name = "message", start = '<message>', lastending = '', ending = "</message", required = false, notfound = ""},
                     {name = "update", start = '<autoupgrade>', lastending = '', ending = "</autoupgrade", required = false, notfound = ""},
                     {name = "location", start = '<location>', lastending = '', ending = "</location", required = false, notfound = ""}},
                  {   --2 ZTV Cats
                     {name = "fstart", start = '="ylwtitle', startplain = true, lastending = "<div", required = true, pageend = 'group_websites', sel_end = '', skip_end = "", anyorder = false, maxretries = 200},
                     {name = "title", start = 'ylwtitle">', lastending = '', ending = "<", required = true, notfound = "Unknown Category"}},
                  {   --3 ZTV Shows
                     {name = "fstart", start = 'title">'..srch_param[1]..'<', startplain = true, lastending = "", required = true, pageend = 'ylwtitle', sel_end = "/a>", skip_end = "", anyorder = false, maxretries = 2},
                     {name = "vidurl", start = 'href="', lastending = '', ending = '"', required = false, requiredbutcont = true, notfound = ""},
                     {name = "title", start = '>', lastending = '', ending = "<", required = false, notfound = "Unknown Show"}},
                  {   --4 ZTV Pages
                     {name = "fstart", start = '"pagination', startplain = true, lastending = "", required = true, pageend = '</div>', sel_end = "onclick", skip_end = "", anyorder = false, maxretries = 2},
                     {name = "page", start = 'pn1=', lastending = '', ending = '"', required = true, notfound = ""}},
                  {   --5 ZTV Episodes
                     {name = 'fstart', start = 'class="videolist', startplain = true, lastending = '', required = true, pageend = '</ul>', sel_end = '</li>', skip_end = '', anyorder = false, maxretries = 20},
                     {name = "vidurl", start = 'href="', lastending = '', ending = '"', required = false, notfound = ""},
                     {name = "thumb", start = 'src="', lastending = '', ending = '"', required = false, notfound = ""},
                     {name = "title", start = 'title="', lastending = '', ending = '"', required = false, notfound = ""}}
                 };
   
   if debug_on then _l("\r\nRunning Scrape Number "..srch_type.."\r\n"); end;

   return Lib_Scrape_Page(url, srch_keys[srch_type], srch_items, s, debug_on);

end;

 

+ Quick Reply