Парсинг - цикл в цикле



  • Всем привет. Столкнулся с проблемой. Пользоваться BAS начал только сегодня. Нужно получить таблицу тарифов с сайта, но не могу циклом получить информацию из страницы. Где я ошибся?
    0_1531092325453_0671e1a7-092b-4a49-9fdf-4d37ea25860c-image.png

    Код скрипта:

    section(1 /*1*/,1 /*1*/,1 /*1*/,0,function(){
       section_start("\u007b\u0022n\u0022:\u0022Initialize\u0022\u007d", 0)!
       _BROWSER_TYPE = 1;
       section_end()!
    
       _call(_on_start, null)!
    
       section_start("", 880471092)!
       /*Dat:eyJzIjoic2V0dmFyaWFibGUiLCJ2IjoxLCJmIjpbXSwidXciOiIwIiwidXQiOiIwIiwidXRvIjoiMCIsInVtIjoiMCIsImQiOlt7ImlkIjoiU2V0VmFyaWFibGVOYW1lIiwidHlwZSI6InZhciIsImRhdGEiOiJwdXRrZmFpbHUifSx7ImlkIjoiU2V0VmFyaWFibGVWYWx1ZSIsInR5cGUiOiJjb25zdHIiLCJkYXRhIjoiRzpcXDExMTEudHh0IiwiY2xhc3MiOiJzdHJpbmcifV19*/
       VAR_PUTKFAILU = "G:\u005c1111.txt"
       section_end()!
    
       section_start("", 866482993)!
       /*Dat:eyJzIjoiZmlsZXN5c3RlbV93cml0ZWZpbGUiLCJ2IjoxLCJmIjpbXSwidXciOiIwIiwidXQiOiIwIiwidXRvIjoiMCIsInVtIjoiMCIsImQiOlt7ImlkIjoiRmlsZSIsInR5cGUiOiJjb25zdHIiLCJkYXRhIjoiW1tQVVRLRkFJTFVdXSIsImNsYXNzIjoic3RyaW5nIn0seyJpZCI6IlZhbHVlIiwidHlwZSI6ImNvbnN0ciIsImRhdGEiOiIgIiwiY2xhc3MiOiJzdHJpbmcifSx7ImlkIjoiQ2hlY2szIiwidHlwZSI6ImNoZWNrIiwiZGF0YSI6ZmFsc2V9LHsiaWQiOiJDaGVjayIsInR5cGUiOiJjaGVjayIsImRhdGEiOmZhbHNlfSx7ImlkIjoiQ2hlY2syIiwidHlwZSI6ImNoZWNrIiwiZGF0YSI6ZmFsc2V9XX0=*/
       native("filesystem", "writefile", JSON.stringify({path: VAR_PUTKFAILU,value: (" ").toString(),base64:false,append:false}))
       section_end()!
    
       section_start("", 422848343)!
       /*Dat:eyJzIjoibG9hZCIsInYiOjEsImYiOltdLCJ1dyI6IjEiLCJ1dCI6IjAiLCJ1dG8iOiIwIiwidW0iOiIwIiwiZCI6W3siaWQiOiJMb2FkVXJsIiwidHlwZSI6ImNvbnN0ciIsImRhdGEiOiJodHRwczovL2NpdHlob3N0LnVhLyIsImNsYXNzIjoic3RyaW5nIn1dfQ==*/
       /*Browser*/
       load("https://cityhost.ua/")!
       section_end()!
    
       section_start("", 271568221)!
       /*Dat:eyJzIjoibG9vcGVsZW1lbnQiLCJ2IjoxLCJmIjpbXSwidXciOiIwIiwidXQiOiIwIiwidXRvIjoiMCIsInVtIjoiMCIsImQiOltdLCJwIjp7ImlzX2ltYWdlIjpmYWxzZSwiY3NzIjoiID5DU1M+ICNob3N0aW5nIHRoZWFkID4gdHIgPiB0aCIsInZlcnNpb24iOiIxLjAiLCJjc3MxIjoiID5DU1M+IHRoZWFkID4gdHIgPiA6bnRoLWNoaWxkKDEpIiwiY3NzMiI6IiIsImNzczMiOiIgPkNTUz4gLmZpcnN0VGgiLCJjdXJyZW50IjoiY3NzIiwibWF0Y2giOiI+TUFUQ0g+PHRoIGNsYXNzPVwiZmlyc3RUaFwiIHNjb3BlPVwiY29sXCI+0KLQsNGA0LjRhDwvdCIsInhwYXRoIjoiID5YUEFUSD4gaWQoXCJjb29sdGFibGVcIikvdGhlYWRbMV0vdHJbMV0vdGhbQGNsYXNzPVwiZmlyc3RUaFwiXSIsImF0IjoiMjA4LCA5NjEiLCJ3ZSI6dHJ1ZSwiZmEiOnRydWV9fQ==*/
       /*Browser*/
       _SELECTOR = " \u003eCSS\u003e #hosting thead \u003e tr \u003e th";
       wait_element(_SELECTOR)!
       get_element_selector(_SELECTOR, true).length()!
       ELEMENT_LENGTH = _result()
       VAR_FOR_EACH_CSS = " \u003eCSS\u003e #hosting thead \u003e tr \u003e th"
       VAR_FOR_EACH_MATCH = "\u003eMATCH\u003e\u003cth class=\u0022firstTh\u0022 scope=\u0022col\u0022\u003eТариф\u003c/t"
       VAR_FOR_EACH_XPATH = " \u003eXPATH\u003e id(\u0022cooltable\u0022)/thead[1]/tr[1]/th[@class=\u0022firstTh\u0022]"
       _do(function(){
       VAR_CYCLE_INDEX = _iterator() - 1
       if(VAR_CYCLE_INDEX >= ELEMENT_LENGTH)_break();
       section_insert()
          section_start("", 173466640)!
          /*Dat:eyJzIjoidGV4dCIsInYiOjEsImYiOltdLCJ1dyI6IjAiLCJ1dCI6IjAiLCJ1dG8iOiIwIiwidW0iOiIwIiwiZCI6W3siaWQiOiJTYXZlVGV4dCIsInR5cGUiOiJ2YXIiLCJkYXRhIjoiUE9MVUNIQUVNSU1ZQVRBUklGQSJ9XSwicCI6eyJpc19pbWFnZSI6ZmFsc2UsImNzcyI6IltbRk9SX0VBQ0hfQ1NTXV0+QVQ+W1tDWUNMRV9JTkRFWF1dIiwidmVyc2lvbiI6IjEuMCIsImNzczEiOiJbW0ZPUl9FQUNIX0NTU11dPkFUPltbQ1lDTEVfSU5ERVhdXSIsImNzczIiOiIiLCJjc3MzIjoiIiwiY3VycmVudCI6ImNzcyIsIm1hdGNoIjoiW1tGT1JfRUFDSF9NQVRDSF1dPkFUPltbQ1lDTEVfSU5ERVhdXSIsInhwYXRoIjoiW1tGT1JfRUFDSF9YUEFUSF1dPkFUPltbQ1lDTEVfSU5ERVhdXSIsImF0IjoiMjE1LCA5NTEiLCJ3ZSI6dHJ1ZSwiZmEiOnRydWV9fQ==*/
          /*Browser*/
          _SELECTOR = VAR_FOR_EACH_CSS + "\u003eAT\u003e" + VAR_CYCLE_INDEX;
          wait_element(_SELECTOR)!
          get_element_selector(_SELECTOR, false).text()!
          VAR_POLUCHAEMIMYATARIFA = _result()
          section_end()!
    
          section_start("", 547527975)!
          /*Dat:eyJzIjoiZm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CJwb3J0XCI6XCJzZWNvbmRcIn19LHtcInR5cGVcIjpcImxpbmtcIixcInNvdXJjZVwiOntcImlkXCI6XCIyXCIsXCJwb3J0XCI6XCItXCJ9LFwidGFyZ2V0XCI6e1wiaWRcIjpcIjBcIixcInBvcnRcIjpcIi1cIn19XSIsImRhdGEiOiIoW1tQT0xVQ0hBRU1JTVlBVEFSSUZBXV0gKyAoXCI7XCIpKSIsImNsYXNzIjoiZXhwcmVzc2lvbiJ9LHsiaWQiOiJDaGVjazMiLCJ0eXBlIjoiY2hlY2siLCJkYXRhIjpmYWxzZX0seyJpZCI6IkNoZWNrIiwidHlwZSI6ImNoZWNrIiwiZGF0YSI6dHJ1ZX0seyJpZCI6IkNoZWNrMiIsInR5cGUiOiJjaGVjayIsImRhdGEiOmZhbHNlfV19*/
          native("filesystem", "writefile", JSON.stringify({path: VAR_PUTKFAILU,value: ((VAR_POLUCHAEMIMYATARIFA + (";"))).toString(),base64:false,append:true}))
          section_end()!
    
       })!
       section_end()!
    
       section_start("", 785972064)!
       /*Dat:eyJzIjoiZmlsZXN5c3RlbV93cml0ZWZpbGUiLCJ2IjoxLCJmIjpbXSwidXciOiIwIiwidXQiOiIwIiwidXRvIjoiMCIsInVtIjoiMCIsImQiOlt7ImlkIjoiRmlsZSIsInR5cGUiOiJjb25zdHIiLCJkYXRhIjoiW1tQVVRLRkFJTFVdXSIsImNsYXNzIjoic3RyaW5nIn0seyJpZCI6IlZhbHVlIiwidHlwZSI6ImNvbnN0ciIsImRhdGEiOiIoXCIgXCIpIiwiY2xhc3MiOiJleHByZXNzaW9uIn0seyJpZCI6IkNoZWNrMyIsInR5cGUiOiJjaGVjayIsImRhdGEiOnRydWV9LHsiaWQiOiJDaGVjayIsInR5cGUiOiJjaGVjayIsImRhdGEiOnRydWV9LHsiaWQiOiJDaGVjazIiLCJ0eXBlIjoiY2hlY2siLCJkYXRhIjpmYWxzZX1dfQ==*/
       native("filesystem", "writefile", JSON.stringify({path: VAR_PUTKFAILU,value: ((" ")).toString() + "\r\n",base64:false,append:true}))
       section_end()!
    
       section_start("", 705619105)!
       /*Dat:eyJzIjoibG9vcGVsZW1lbnQiLCJ2IjoxLCJmIjpbXSwidXciOiIwIiwidXQiOiIwIiwidXRvIjoiMCIsInVtIjoiMCIsImQiOltdLCJwIjp7ImlzX2ltYWdlIjpmYWxzZSwiY3NzIjoiID5DU1M+IHRib2R5IHRyIiwidmVyc2lvbiI6IjEuMCIsImNzczEiOiIgPkNTUz4gdGJvZHkgPiA6bnRoLWNoaWxkKDEpID4gOm50aC1jaGlsZCgxKSIsImNzczIiOiIiLCJjc3MzIjoiID5DU1M+IC5kYXJrID4gOm50aC1jaGlsZCgxKSIsImN1cnJlbnQiOiJjc3MiLCJtYXRjaCI6Ij5NQVRDSD48dGQ+0JzQtdGB0YLQviDQvdCwIFNTRCDQtNC40YHQutC1PC90ZD4iLCJ4cGF0aCI6IiA+WFBBVEg+IGlkKFwiY29vbHRhYmxlXCIpL3Rib2R5WzFdL3RyW0BjbGFzcz1cImRhcmtcIl0vdGRbMV0iLCJhdCI6IjIxNSwgMTAzNSIsIndlIjp0cnVlLCJmYSI6dHJ1ZX19*/
       /*Browser*/
       _SELECTOR = " \u003eCSS\u003e tbody tr";
       wait_element(_SELECTOR)!
       get_element_selector(_SELECTOR, true).length()!
       ELEMENT_LENGTH = _result()
       VAR_FOR_EACH_CSS = " \u003eCSS\u003e tbody tr"
       VAR_FOR_EACH_MATCH = "\u003eMATCH\u003e\u003ctd\u003eМесто на SSD диске\u003c/td\u003e"
       VAR_FOR_EACH_XPATH = " \u003eXPATH\u003e id(\u0022cooltable\u0022)/tbody[1]/tr[@class=\u0022dark\u0022]/td[1]"
       _do(function(){
       VAR_CYCLE_INDEX = _iterator() - 1
       if(VAR_CYCLE_INDEX >= ELEMENT_LENGTH)_break();
       section_insert()
          section_start("", 278728424)!
          /*Dat:eyJzIjoibG9vcGVsZW1lbnQiLCJ2IjoxLCJmIjpbXSwidXciOiIwIiwidXQiOiIwIiwidXRvIjoiMCIsInVtIjoiMCIsImQiOltdLCJwIjp7ImlzX2ltYWdlIjpmYWxzZSwiY3NzIjoiID5DU1M+IHRib2R5IHRyIiwidmVyc2lvbiI6IjEuMCIsImNzczEiOiIgPkNTUz4gdGJvZHkgPiA6bnRoLWNoaWxkKDEpID4gOm50aC1jaGlsZCgxKSIsImNzczIiOiIiLCJjc3MzIjoiID5DU1M+IC5kYXJrID4gOm50aC1jaGlsZCgxKSIsImN1cnJlbnQiOiJjc3MiLCJtYXRjaCI6Ij5NQVRDSD48dGQ+0JzQtdGB0YLQviDQvdCwIFNTRCDQtNC40YHQutC1PC90ZD4iLCJ4cGF0aCI6IiA+WFBBVEg+IGlkKFwiY29vbHRhYmxlXCIpL3Rib2R5WzFdL3RyW0BjbGFzcz1cImRhcmtcIl0vdGRbMV0iLCJhdCI6IjIwNCwgMTAzMSIsIndlIjp0cnVlLCJmYSI6dHJ1ZX19*/
          /*Browser*/
          _SELECTOR = " \u003eCSS\u003e tbody tr";
          wait_element(_SELECTOR)!
          get_element_selector(_SELECTOR, true).length()!
          ELEMENT_LENGTH = _result()
          VAR_FOR_EACH_CSS = " \u003eCSS\u003e tbody tr"
          VAR_FOR_EACH_MATCH = "\u003eMATCH\u003e\u003ctd\u003eМесто на SSD диске\u003c/td\u003e"
          VAR_FOR_EACH_XPATH = " \u003eXPATH\u003e id(\u0022cooltable\u0022)/tbody[1]/tr[@class=\u0022dark\u0022]/td[1]"
          _do(function(){
          VAR_CYCLE_INDEX = _iterator() - 1
          if(VAR_CYCLE_INDEX >= ELEMENT_LENGTH)_break();
          section_insert()
             section_start("", 293492867)!
             /*Dat:eyJzIjoidGV4dCIsInYiOjEsImYiOltdLCJ1dyI6IjAiLCJ1dCI6IjAiLCJ1dG8iOiIwIiwidW0iOiIwIiwiZCI6W3siaWQiOiJTYXZlVGV4dCIsInR5cGUiOiJ2YXIiLCJkYXRhIjoiWk5BQ0hFTklFVEFSSUZBIn1dLCJwIjp7ImlzX2ltYWdlIjpmYWxzZSwiY3NzIjoiW1tGT1JfRUFDSF9DU1NdXT5BVD5bW0NZQ0xFX0lOREVYXV0gPkNTUz4gdGQiLCJ2ZXJzaW9uIjoiMS4wIiwiY3NzMSI6IltbRk9SX0VBQ0hfQ1NTXV0+QVQ+W1tDWUNMRV9JTkRFWF1dIiwiY3NzMiI6IiIsImNzczMiOiIiLCJjdXJyZW50IjoiY3NzIiwibWF0Y2giOiJbW0ZPUl9FQUNIX01BVENIXV0+QVQ+W1tDWUNMRV9JTkRFWF1dIiwieHBhdGgiOiJbW0ZPUl9FQUNIX1hQQVRIXV0+QVQ+W1tDWUNMRV9JTkRFWF1dIiwiYXQiOiIxNjcsIDEwMzgiLCJ3ZSI6ZmFsc2UsImZhIjpmYWxzZX19*/
             /*Browser*/
             _SELECTOR = VAR_FOR_EACH_CSS + "\u003eAT\u003e" + VAR_CYCLE_INDEX + " \u003eCSS\u003e td";
             get_element_selector(_SELECTOR, false).nowait().text()!
             VAR_ZNACHENIETARIFA = _result()
             section_end()!
    
             section_start("", 226444668)!
             /*Dat:eyJzIjoiZmlsZXN5c3RlbV93cml0ZWZpbGUiLCJ2IjoxLCJmIjpbXSwidXciOiIwIiwidXQiOiIwIiwidXRvIjoiMCIsInVtIjoiMCIsImQiOlt7ImlkIjoiRmlsZSIsInR5cGUiOiJjb25zdHIiLCJkYXRhIjoiW1tQVVRLRkFJTFVdXSIsImNsYXNzIjoic3RyaW5nIn0seyJpZCI6IlZhbHVlIiwidHlwZSI6ImNvbnN0ciIsImRhdGEiOiJbW1pOQUNIRU5JRVRBUklGQV1dOyIsImNsYXNzIjoic3RyaW5nIn0seyJpZCI6IkNoZWNrMyIsInR5cGUiOiJjaGVjayIsImRhdGEiOmZhbHNlfSx7ImlkIjoiQ2hlY2siLCJ0eXBlIjoiY2hlY2siLCJkYXRhIjp0cnVlfSx7ImlkIjoiQ2hlY2syIiwidHlwZSI6ImNoZWNrIiwiZGF0YSI6ZmFsc2V9XX0=*/
             native("filesystem", "writefile", JSON.stringify({path: VAR_PUTKFAILU,value: (VAR_ZNACHENIETARIFA + ";").toString(),base64:false,append:true}))
             section_end()!
    
          })!
          section_end()!
    
          section_start("", 929192337)!
          /*Dat:eyJzIjoiZmlsZXN5c3RlbV93cml0ZWZpbGUiLCJ2IjoxLCJmIjpbXSwidXciOiIwIiwidXQiOiIwIiwidXRvIjoiMCIsInVtIjoiMCIsImQiOlt7ImlkIjoiRmlsZSIsInR5cGUiOiJjb25zdHIiLCJkYXRhIjoiW1tQVVRLRkFJTFVdXSIsImNsYXNzIjoic3RyaW5nIn0seyJpZCI6IlZhbHVlIiwidHlwZSI6ImNvbnN0ciIsImRhdGEiOiIgIiwiY2xhc3MiOiJzdHJpbmcifSx7ImlkIjoiQ2hlY2szIiwidHlwZSI6ImNoZWNrIiwiZGF0YSI6dHJ1ZX0seyJpZCI6IkNoZWNrIiwidHlwZSI6ImNoZWNrIiwiZGF0YSI6dHJ1ZX0seyJpZCI6IkNoZWNrMiIsInR5cGUiOiJjaGVjayIsImRhdGEiOmZhbHNlfV19*/
          native("filesystem", "writefile", JSON.stringify({path: VAR_PUTKFAILU,value: (" ").toString() + "\r\n",base64:false,append:true}))
          section_end()!
    
       })!
       section_end()!
    
    })!
    

    В результате нормально парсятся названия тарифов, и далее только первый столбец... Прошу помощи.
    `



  • @rFox Здравствуй тёзка :D
    По скриншоту ни чего не понятно. Прикреплять скрипт к посту лучше файлом, делается кнопкой 0_1531130585384_на форум 17.png



  • 0_1531166162381_cityhost.xml

    Загрузил. Надеюсь на помощь.

    P.S. И правда тёзка ))))