guitarplayer616

parse_items

Aug 13th, 2021 (edited)
1,203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. function push_items(count, string) {
  2.     var data = JSON.parse(string)
  3.     parse_x_items(count, data)
  4.     return JSON.stringify(data)
  5. }
  6.  
  7. function parse_x_items(count, data) {
  8.     var pages = Math.ceil(count/50)
  9.     for (var i = 0; i<pages; i++){
  10.         parse_items(data)
  11.         document.querySelector("#lv-items > div.listview-band-top > div.listview-nav > a:nth-child(5)").click()
  12.     }
  13.     return data
  14. }
  15.  
  16. function parse_items(items) {
  17.     var trs = document.querySelectorAll("#lv-items > div.listview-scroller-horizontal > div > table > tbody > tr")
  18.     trs.forEach(tr => items.push(parse_row(tr)))
  19.     return items
  20. }
  21.  
  22. function parse_row(row) {
  23.     var link = row.querySelector("td:nth-child(3) > div > a")
  24.     var rarity = link.className
  25.     var name_and_ID = link.href
  26.     var ilvl = row.querySelector("td:nth-child(4)").textContent
  27.     return [name_and_ID, rarity, ilvl]
  28. }
  29.  
  30. function to_json(list) {
  31.     return console.log(JSON.stringify(list))
  32. }
Add Comment
Please, Sign In to add comment