guitarplayer616

parseEnchants

Jul 22nd, 2021 (edited)
1,348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function parse_x_enchants(count, data) {
  2.     var pages = Math.ceil(count/50)
  3.     for (var i = 0; i<pages; i++){
  4.         parse_enchants(data)
  5.         document.querySelector("#lv-spells > div.listview-band-top > div.listview-nav > a:nth-child(5)").click()
  6.     }
  7.     return data
  8. }
  9.  
  10. function parse_all(data) {
  11.     parse_enchants(data)
  12.     while (document.querySelector("#lv-spells > div.listview-band-top > div.listview-nav > a:nth-child(5)").getAttribute('data-active') === "yes") {
  13.         document.querySelector("#lv-spells > div.listview-band-top > div.listview-nav > a:nth-child(5)").click()
  14.         parse_enchants(data)
  15.     }
  16.     return data
  17. }
  18.  
  19. function parse_enchants(data) {
  20.     var trs = document.querySelectorAll("#lv-spells > div.listview-scroller-horizontal > div > table > tbody > tr")
  21.     for (var tr of trs) {
  22.         var row = []
  23.         row.push(tr.querySelector("td:nth-child(2) > div > a").text)
  24.         for (var i=1;i<=4;i++){
  25.             row.push(tr.querySelector("td:nth-child(5) > div:nth-child(2) > span.r"+String(i))?.textContent)
  26.         }
  27.         tr.querySelectorAll("td:nth-child(3) > div > a, span > div:nth-child(1)").forEach(element => element?.href? row.push(element.href) : row.push(element.innerHTML))
  28.         row.push(tr.querySelector("td:nth-child(4)")?.textContent)
  29.         data.push(row)
  30.     }
  31.     return data
  32. }
  33.  
  34. var data = []
  35. parse_x_enchants(385, data)
  36. console.log(JSON.stringify(data))
Add Comment
Please, Sign In to add comment