text: var { _, d3, fs, glob, io, queue, request } = require('scrape-stl')
  
  var q = queue(8)
  
  //copy(str.split('option value="').map(d => d.split('"')[0]))
  var slugs = [
    "Concept:All-Star 2013 Shanghai",
    "Concept:All-Star 2014 Paris",
    "Concept:All-Star 2015 IWC Melbourne",
    "Concept:All-Star 2015 Los Angeles",
    "Concept:All-Star 2016 Barcelona",
    "Concept:All-Star 2016 IWC Barcelona",
    "Concept:BRCC 2016 Summer",
    "Concept:BRCC 2016 Summer Playoffs",
    "Concept:BRCC 2016 Summer Qualifier",
    "Concept:BRCC 2016 Winter",
    "Concept:BRCC 2016 Winter Playoffs",
    "Concept:BRCC 2016 Winter Promotion",
    "Concept:BRCC 2017 Summer",
    "Concept:BRCC 2017 Summer Playoffs",
    "Concept:BRCC 2017 Summer Promotion",
    "Concept:BRCC 2017 Winter",
    "Concept:BRCC 2017 Winter Promotion",
    "Concept:BRMA 2016 Rio",
    "Concept:Battle of the Atlantic 2013",
    "Concept:Brazil Mega Cup 2015",
    "Concept:Brazil Regional Finals 2014",
    "Concept:Brazilian Champions Series 2014",
    "Concept:CBLOL 2015 Summer",
    "Concept:CBLOL 2015 Summer Playoffs",
    "Concept:CBLOL 2015 Winter",
    "Concept:CBLOL 2015 Winter Playoffs",
    "Concept:CBLOL 2016 Summer",
    "Concept:CBLOL 2016 Summer Playoffs",
    "Concept:CBLOL 2016 Summer Promotion",
    "Concept:CBLOL 2016 Winter",
    "Concept:CBLOL 2016 Winter Playoffs",
    "Concept:CBLOL 2016 Winter Promotion",
    "Concept:CBLOL 2017 Summer",
    "Concept:CBLOL 2017 Summer Playoffs",
    "Concept:CBLOL 2017 Summer Promotion",
    "Concept:CBLOL 2017 Winter",
    "Concept:CBLOL 2017 Winter Promotion",
    "Concept:CDL Sur 2017 Opening Playoffs",
    "Concept:CK 2016 Spring",
    "Concept:CK 2016 Spring Playoffs",
    "Concept:CK 2016 Summer",
    "Concept:CK 2016 Summer Playoffs",
    "Concept:CK 2017 Spring",
    "Concept:CK 2017 Spring Playoffs",
    "Concept:CK 2017 Summer Promotion",
    "Concept:CLS 2017 Closing",
    "Concept:CLS 2017 Closing Promotion",
    "Concept:CLS 2017 Opening",
    "Concept:CLS 2017 Opening Playoffs",
    "Concept:CLS 2017 Opening Promotion",
    "Concept:CLS 2017 Preseason",
    "Concept:Champions 2012 Spring",
    "Concept:Champions 2012 Summer",
    "Concept:Champions 2013 Spring",
    "Concept:Champions 2013 Summer",
    "Concept:Champions 2013 Winter",
    "Concept:Champions 2014 Spring",
    "Concept:Champions 2014 Summer",
    "Concept:Champions 2014 Winter",
    "Concept:Champions 2015 Spring",
    "Concept:Champions 2015 Spring Playoffs",
    "Concept:Champions 2015 Spring Preseason",
    "Concept:Champions 2015 Summer",
    "Concept:Champions 2015 Summer Playoffs",
    "Concept:Champions 2015 Summer Promotion",
    "Concept:China Regional Finals 2014",
    "Concept:China Regional Finals 2015",
    "Concept:China Regional Finals 2016",
    "Concept:China Regional Finals Season 3",
    "Concept:Copa Go4gold 2016",
    "Concept:Demacia Cup 2015 Grand Finals",
    "Concept:Demacia Cup 2016",
    "Concept:DreamHack Summer 2012",
    "Concept:ESL BRPL 2016 Season 1",
    "Concept:ESL BRPL Season 1 Playoffs",
    "Concept:ESL BRPL Season 2",
    "Concept:ESL BRPL Season 2 Playoffs",
    "Concept:ESL BRPL Season 2 Promotion",
    "Concept:ESL BRPL Season 3 Promotion",
    "Concept:EU LCS 2013 Spring",
    "Concept:EU LCS 2013 Spring Playoffs",
    "Concept:EU LCS 2013 Summer Playoffs",
    "Concept:EU LCS 2013 Summer Promotion",
    "Concept:EU LCS 2014 Spring",
    "Concept:EU LCS 2014 Spring Playoffs",
    "Concept:EU LCS 2014 Spring Prequalifier 1",
    "Concept:EU LCS 2014 Spring Prequalifier 2",
    "Concept:EU LCS 2014 Spring Prequalifier Gamescom",
    "Concept:EU LCS 2014 Spring Promotion",
    "Concept:EU LCS 2014 Summer",
    "Concept:EU LCS 2015 Spring",
    "Concept:EU LCS 2015 Spring Expansion",
    "Concept:EU LCS 2015 Spring Playoffs",
    "Concept:EU LCS 2015 Spring Promotion",
    "Concept:EU LCS 2015 Summer",
    "Concept:EU LCS 2015 Summer Playoffs",
    "Concept:EU LCS 2015 Summer Promotion",
    "Concept:EU LCS 2016 Spring",
    "Concept:EU LCS 2016 Spring Playoffs",
    "Concept:EU LCS 2016 Spring Promotion",
    "Concept:EU LCS 2016 Summer",
    "Concept:EU LCS 2016 Summer Playoffs",
    "Concept:EU LCS 2016 Summer Promotion",
    "Concept:EU LCS 2017 Spring",
    "Concept:EU LCS 2017 Spring Playoffs",
    "Concept:EU LCS 2017 Spring Promotion",
    "Concept:EU LCS 2017 Summer",
    "Concept:EU LCS 2017 Summer Promotion",
    "Concept:EU Regional Finals 2015",
    "Concept:EU Regional Finals 2016",
    "Concept:EU Regional Finals Season 2",
    "Concept:EUCS 2015 Spring",
    "Concept:EUCS 2015 Spring Qualifier",
    "Concept:EUCS 2015 Summer Qualifier",
    "Concept:EUCS 2016 Spring",
    "Concept:EUCS 2016 Spring Playoffs",
    "Concept:EUCS 2016 Spring Qualifiers",
    "Concept:EUCS 2016 Summer",
    "Concept:EUCS 2016 Summer Playoffs",
    "Concept:EUCS 2016 Summer Qualifiers",
    "Concept:EUCS 2017 Spring",
    "Concept:EUCS 2017 Spring Playoffs",
    "Concept:EUCS 2017 Spring Qualifiers",
    "Concept:EUCS 2017 Summer Qualifiers",
    "Concept:GPL 2014 Spring",
    "Concept:GPL 2016 Spring",
    "Concept:GPL 2016 Summer",
    "Concept:GPL 2017 Spring",
    "Concept:Garena Regional Finals 2014",
    "Concept:IEM Season 10 Cologne",
    "Concept:IEM Season 10 San Jose",
    "Concept:IEM Season 10 World Championship",
    "Concept:IEM Season 11 Challenger",
    "Concept:IEM Season 11 Gyeonggi",
    "Concept:IEM Season 11 Oakland",
    "Concept:IEM Season 11 World Championship",
    "Concept:IEM Season 6 Kiev",
    "Concept:IEM Season 6 World Championship",
    "Concept:IEM Season 7 Cologne",
    "Concept:IEM Season 7 Katowice",
    "Concept:IEM Season 7 Singapore",
    "Concept:IEM Season 7 World Championship",
    "Concept:IEM Season 8 Cologne",
    "Concept:IEM Season 8 Cologne Amateur",
    "Concept:IEM Season 8 Sao Paulo",
    "Concept:IEM Season 8 Shanghai",
    "Concept:IEM Season 8 World Championship",
    "Concept:IEM Season 9 Cologne",
    "Concept:IEM Season 9 San Jose",
    "Concept:IEM Season 9 Shenzhen",
    "Concept:IEM Season 9 Taipei",
    "Concept:IEM Season 9 World Championship",
    "Concept:IWCI 2015",
    "Concept:IWCI 2016",
    "Concept:IWCQ 2016",
    "Concept:IWCT 2013",
    "Concept:IWCT 2014",
    "Concept:IWCT 2015 Chile",
    "Concept:IWCT 2015 Turkey",
    "Concept:KeSPA Cup 2015",
    "Concept:KeSPA Cup 2016",
    "Concept:Korea Regional Finals 2014",
    "Concept:Korea Regional Finals 2015",
    "Concept:Korea Regional Finals 2016",
    "Concept:Korea Regional Finals Season 2",
    "Concept:Korea Regional Finals Season 3",
    "Concept:LAC 2014 Colombia",
    "Concept:LAC 2015 Opening Grand Final",
    "Concept:LAN 2015 Closing Cup",
    "Concept:LAN 2015 Closing Cup Playoffs",
    "Concept:LAN 2015 Opening Cup",
    "Concept:LAN 2015 Opening Cup Playoffs",
    "Concept:LAN 2016 Closing Cup",
    "Concept:LAN 2016 Closing Cup Playoffs",
    "Concept:LAN 2016 Closing Cup Promotion",
    "Concept:LAN 2016 Opening Cup",
    "Concept:LAN 2016 Opening Cup Playoffs",
    "Concept:LAS 2015 Closing Cup",
    "Concept:LAS 2015 Closing Cup Playoffs",
    "Concept:LAS 2015 Opening Cup",
    "Concept:LAS 2015 Opening Cup Playoffs",
    "Concept:LAS 2016 Closing Cup",
    "Concept:LAS 2016 Closing Cup Playoffs",
    "Concept:LAS 2016 Closing Cup Promotion",
    "Concept:LAS 2016 Opening Cup",
    "Concept:LAS 2016 Opening Cup Playoffs",
    "Concept:LCK 2016 Spring",
    "Concept:LCK 2016 Spring Playoffs",
    "Concept:LCK 2016 Summer",
    "Concept:LCK 2016 Summer Playoffs",
    "Concept:LCK 2016 Summer Promotion",
    "Concept:LCK 2017 Spring",
    "Concept:LCK 2017 Spring Playoffs",
    "Concept:LCK 2017 Spring Promotion",
    "Concept:LCK 2017 Summer",
    "Concept:LCK 2017 Summer Promotion",
    "Concept:LCL 2016 Spring",
    "Concept:LCL 2016 Spring Playoffs",
    "Concept:LCL 2016 Summer",
    "Concept:LCL 2016 Summer Playoffs",
    "Concept:LCL 2016 Summer Promotion",
    "Concept:LCL 2017 Spring",
    "Concept:LCL 2017 Spring Playoffs",
    "Concept:LCL 2017 Spring Promotion",
    "Concept:LCL 2017 Summer",
    "Concept:LCL 2017 Summer Promotion",
    "Concept:LJL 2015 Grand Finals",
    "Concept:LJL 2015 Season 1",
    "Concept:LJL 2015 Season 2",
    "Concept:LJL 2016 Spring",
    "Concept:LJL 2016 Spring Playoffs",
    "Concept:LJL 2016 Summer",
    "Concept:LJL 2016 Summer Playoffs",
    "Concept:LJL 2016 Summer Promotion",
    "Concept:LJL 2017 Spring",
    "Concept:LJL 2017 Spring Playoffs",
    "Concept:LJL 2017 Spring Promotion",
    "Concept:LJL 2017 Summer",
    "Concept:LJL 2017 Summer Promotion",
    "Concept:LJLCS 2016 Spring",
    "Concept:LJLCS 2016 Summer",
    "Concept:LLN 2017 Closing",
    "Concept:LLN 2017 Closing Promotion",
    "Concept:LLN 2017 Opening",
    "Concept:LLN 2017 Opening Playoffs",
    "Concept:LLN 2017 Opening Promotion",
    "Concept:LMS 2015 Spring",
    "Concept:LMS 2015 Spring Playoffs",
    "Concept:LMS 2015 Spring Qualifiers",
    "Concept:LMS 2015 Summer",
    "Concept:LMS 2015 Summer Playoffs",
    "Concept:LMS 2016 Spring",
    "Concept:LMS 2016 Spring Playoffs",
    "Concept:LMS 2016 Spring Promotion",
    "Concept:LMS 2016 Summer",
    "Concept:LMS 2016 Summer Playoffs",
    "Concept:LMS 2016 Summer Promotion",
    "Concept:LMS 2017 Spring",
    "Concept:LMS 2017 Spring Playoffs",
    "Concept:LMS 2017 Spring Promotion",
    "Concept:LMS 2017 Summer",
    "Concept:LPL 2014 Spring",
    "Concept:LPL 2014 Spring Playoffs",
    "Concept:LPL 2014 Summer",
    "Concept:LPL 2014 Summer Playoffs",
    "Concept:LPL 2015 Spring",
    "Concept:LPL 2015 Spring Playoffs",
    "Concept:LPL 2015 Summer",
    "Concept:LPL 2015 Summer Playoffs",
    "Concept:LPL 2015 Summer Promotion",
    "Concept:LPL 2016 Spring",
    "Concept:LPL 2016 Spring Playoffs",
    "Concept:LPL 2016 Spring Promotion",
    "Concept:LPL 2016 Summer",
    "Concept:LPL 2016 Summer Playoffs",
    "Concept:LPL 2016 Summer Promotion",
    "Concept:LPL 2017 Spring",
    "Concept:LPL 2017 Spring Playoffs",
    "Concept:LPL 2017 Spring Promotion",
    "Concept:LPL 2017 Summer",
    "Concept:LPL 2017 Summer Promotion",
    "Concept:LSPL 2015 Spring Playoffs",
    "Concept:LSPL 2016 Spring",
    "Concept:LSPL 2016 Spring Playoffs",
    "Concept:LSPL 2016 Spring Relegation",
    "Concept:LSPL 2016 Summer",
    "Concept:LSPL 2016 Summer Playoffs",
    "Concept:LSPL 2016 Summer Relegation",
    "Concept:LSPL 2017 Spring",
    "Concept:LSPL 2017 Spring Relegation",
    "Concept:League of Origin 2017",
    "Concept:LoL Masters 2014",
    "Concept:Logitech Challenge BR 2016",
    "Concept:MLG 2012 Fall",
    "Concept:MSI 2015",
    "Concept:MSI 2016",
    "Concept:MSI 2017 Main Event",
    "Concept:MSI 2017 Play-In",
    "Concept:NA LCS 2013 Spring",
    "Concept:NA LCS 2013 Spring Playoffs",
    "Concept:NA LCS 2013 Summer",
    "Concept:NA LCS 2013 Summer Playoffs",
    "Concept:NA LCS 2013 Summer Promotion",
    "Concept:NA LCS 2014 Spring",
    "Concept:NA LCS 2014 Spring Playoffs",
    "Concept:NA LCS 2014 Spring Prequalifier 1",
    "Concept:NA LCS 2014 Spring Prequalifier 2",
    "Concept:NA LCS 2014 Spring Prequalifier PAX",
    "Concept:NA LCS 2014 Spring Promotion",
    "Concept:NA LCS 2014 Summer",
    "Concept:NA LCS 2015 Spring",
    "Concept:NA LCS 2015 Spring Expansion",
    "Concept:NA LCS 2015 Spring Playoffs",
    "Concept:NA LCS 2015 Spring Promotion",
    "Concept:NA LCS 2015 Summer",
    "Concept:NA LCS 2015 Summer Playoffs",
    "Concept:NA LCS 2015 Summer Promotion",
    "Concept:NA LCS 2016 Spring",
    "Concept:NA LCS 2016 Spring Playoffs",
    "Concept:NA LCS 2016 Spring Promotion",
    "Concept:NA LCS 2016 Summer",
    "Concept:NA LCS 2016 Summer Playoffs",
    "Concept:NA LCS 2016 Summer Promotion",
    "Concept:NA LCS 2017 Spring",
    "Concept:NA LCS 2017 Spring Playoffs",
    "Concept:NA LCS 2017 Spring Promotion",
    "Concept:NA LCS 2017 Summer",
    "Concept:NA LCS 2017 Summer Promotion",
    "Concept:NA Regional Finals 2015",
    "Concept:NA Regional Finals 2016",
    "Concept:NACS 2015 Spring",
    "Concept:NACS 2015 Spring Qualifier",
    "Concept:NACS 2015 Summer",
    "Concept:NACS 2016 Spring",
    "Concept:NACS 2016 Spring Playoffs",
    "Concept:NACS 2016 Spring Qualifiers",
    "Concept:NACS 2016 Summer",
    "Concept:NACS 2016 Summer Playoffs",
    "Concept:NACS 2016 Summer Qualifiers",
    "Concept:NACS 2017 Qualifiers",
    "Concept:NACS 2017 Spring",
    "Concept:NACS 2017 Spring Playoffs",
    "Concept:NACS 2017 Spring Qualifiers",
    "Concept:NACS 2017 Summer",
    "Concept:NACS 2017 Summer Qualifiers",
    "Concept:NEST 2014",
    "Concept:NEST 2015",
    "Concept:NLB 2014 Summer",
    "Concept:OCS 2016 Split 1",
    "Concept:OCS 2016 Split 1 Playoffs",
    "Concept:OCS 2016 Split 2",
    "Concept:OCS 2016 Split 2 Playoffs",
    "Concept:OCS 2017 Split 1",
    "Concept:OCS 2017 Split 1 Playoffs",
    "Concept:OGN LoL Invitational 2012",
    "Concept:OPL 2015 Split 1",
    "Concept:OPL 2015 Split 1 Playoffs",
    "Concept:OPL 2015 Split 2",
    "Concept:OPL 2015 Split 2 Playoffs",
    "Concept:OPL 2015 Split 2 Promotion",
    "Concept:OPL 2016 Split 1",
    "Concept:OPL 2016 Split 1 Playoffs",
    "Concept:OPL 2016 Split 1 Promotion",
    "Concept:OPL 2016 Split 2",
    "Concept:OPL 2016 Split 2 Playoffs",
    "Concept:OPL 2016 Split 2 Promotion",
    "Concept:OPL 2017 Split 1",
    "Concept:OPL 2017 Split 1 Playoffs",
    "Concept:OPL 2017 Split 1 Promotion",
    "Concept:OPL 2017 Split 2 Promotion",
    "Concept:PGL Legends of the Rift Season 1",
    "Concept:SLTV Challenger 2016 Spring",
    "Concept:SLTV Challenger 2016 Spring Playoffs",
    "Concept:SLTV Challenger 2016 Summer",
    "Concept:SLTV Challenger 2016 Summer Playoffs",
    "Concept:SLTV StarSeries 2015 Spring",
    "Concept:SLTV StarSeries 2015 Spring Finals",
    "Concept:SLTV StarSeries 2015 Summer",
    "Concept:SLTV StarSeries 2015 Summer Finals",
    "Concept:SLTV StarSeries 2015 Summer Promotion",
    "Concept:TCL 2015 Summer",
    "Concept:TCL 2015 Summer Playoffs",
    "Concept:TCL 2015 Summer Qualifiers",
    "Concept:TCL 2015 Winter",
    "Concept:TCL 2015 Winter Playoffs",
    "Concept:TCL 2016 Summer",
    "Concept:TCL 2016 Summer Playoffs",
    "Concept:TCL 2016 Summer Qualifiers",
    "Concept:TCL 2016 Winter",
    "Concept:TCL 2016 Winter Playoffs",
    "Concept:TCL 2016 Winter Qualifiers",
    "Concept:TCL 2017 Summer Qualifiers",
    "Concept:TCL 2017 Winter",
    "Concept:TCL 2017 Winter Playoffs",
    "Concept:TCL 2017 Winter Qualifiers",
    "Concept:TPL 2016 Summer Finals",
    "Concept:TPL 2016 Winter Finals",
    "Concept:TPL 2017 Winter",
    "Concept:Taiwan Regional Finals 2016",
    "Concept:World Championship 2014",
    "Concept:World Championship 2015",
    "Concept:World Championship 2016",
    "Concept:World Championship Season 1",
    "Concept:World Championship Season 2",
    "Concept:World Championship Season 3",
    "Concept:World Cyber Arena 2015",
    "Concept:XLG SuperCup 2016"
  ]
  
  var downloaded = glob
    .sync(__dirname + '/raw/*.html')
    .map(d => d.replace('.html', '').split('/').slice(-1)[0])
  
  console.log(slugs.length)
  slugs = slugs.filter(d => !downloaded.includes(d))
  console.log(slugs.length)
  
  
  
  
  
  // var url = 'http://lol.esportswikis.com/wiki/Special:RunQuery/MatchHistoryTournament?MHT%5Btournament%5D=Concept:LCK%202017%20Summer&MHT%5Btext%5D=Yes&wpRunQuery=true'
  
  var baseurl = 'http://lol.esportswikis.com/wiki/Special:RunQuery/MatchHistoryTournament?MHT%5Btournament%5D=SLUG&MHT%5Btext%5D=Yes&wpRunQuery=true'
  
  
  slugs.forEach(d => q.defer(downloadPage, d)) 
  
  
  function downloadPage(slug, cb){
    var url = baseurl.replace('SLUG', slug.replace(/ /g, '%20'))
    console.log(url)
  
    request(url, function(err, res){
      console.log(slug, err)
      cb()
      if (!res || !res.body || res.body.length < 50) return
      fs.writeFile(__dirname + `/raw/${slug}.html`, res.body, function(){})
    })
  
  }
  