This commit is contained in:
Jay 2019-01-08 22:07:41 +08:00
parent 513353a2a0
commit fcc53ee3e7
3 changed files with 42 additions and 36 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
node_modules/ node_modules/
*.swp

View File

@ -1,18 +1,23 @@
const { Builder, By, Key, until } = require('selenium-webdriver') const { Builder, By, Key, until } = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome') const chrome = require('selenium-webdriver/chrome')
const firefox = require('selenium-webdriver/firefox')
const setsUrl = 'https://www.echomtg.com/sets/' const setsUrl = 'https://www.echomtg.com/sets/'
const setsClass = '.main.marketAnalysis.sets' const setsClass = '.main.marketAnalysis.sets'
;(async () => { ;(async () => {
let cOpts = new chrome.Options() let ffOpts = new firefox.Options()
cOpts.headless() ffOpts.headless()
cOpts.setChromeBinaryPath('/Applications/Google Chrome.app/Contents/MacOS/Google Chrome') ffOpts.setBinary('/root/apps/firefox/firefox')
let driver = await new Builder().forBrowser('firefox').setFirefoxOptions(ffOpts).build()
let driver = await new Builder().forBrowser('chrome').setChromeOptions(cOpts).build()
await driver.get(setsUrl) await driver.get(setsUrl)
let el = await driver.findElement(By.css(setsClass)) let el = await driver.findElement(By.css(setsClass))
console.log(await el.getText()) let sets = await el.findElements(By.css('h4>a'))
for (let it of sets) {
console.log(await it.getText())
}
//console.log(sets)
})().catch(console.warn) })().catch(console.warn)

60
package-lock.json generated
View File

@ -14,7 +14,7 @@
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": { "requires": {
"balanced-match": "1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
} }
}, },
@ -48,12 +48,12 @@
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz",
"integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==",
"requires": { "requires": {
"fs.realpath": "1.0.0", "fs.realpath": "^1.0.0",
"inflight": "1.0.6", "inflight": "^1.0.4",
"inherits": "2.0.3", "inherits": "2",
"minimatch": "3.0.4", "minimatch": "^3.0.4",
"once": "1.4.0", "once": "^1.3.0",
"path-is-absolute": "1.0.1" "path-is-absolute": "^1.0.0"
} }
}, },
"immediate": { "immediate": {
@ -66,8 +66,8 @@
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"requires": { "requires": {
"once": "1.4.0", "once": "^1.3.0",
"wrappy": "1.0.2" "wrappy": "1"
} }
}, },
"inherits": { "inherits": {
@ -85,11 +85,11 @@
"resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz", "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.1.5.tgz",
"integrity": "sha512-5W8NUaFRFRqTOL7ZDDrx5qWHJyBXy6velVudIzQUSoqAAYqzSh2Z7/m0Rf1QbmQJccegD0r+YZxBjzqoBiEeJQ==", "integrity": "sha512-5W8NUaFRFRqTOL7ZDDrx5qWHJyBXy6velVudIzQUSoqAAYqzSh2Z7/m0Rf1QbmQJccegD0r+YZxBjzqoBiEeJQ==",
"requires": { "requires": {
"core-js": "2.3.0", "core-js": "~2.3.0",
"es6-promise": "3.0.2", "es6-promise": "~3.0.2",
"lie": "3.1.1", "lie": "~3.1.0",
"pako": "1.0.7", "pako": "~1.0.2",
"readable-stream": "2.0.6" "readable-stream": "~2.0.6"
} }
}, },
"lie": { "lie": {
@ -97,7 +97,7 @@
"resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
"integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=", "integrity": "sha1-mkNrLMd0bKWd56QfpGmz77dr2H4=",
"requires": { "requires": {
"immediate": "3.0.6" "immediate": "~3.0.5"
} }
}, },
"minimatch": { "minimatch": {
@ -105,7 +105,7 @@
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": { "requires": {
"brace-expansion": "1.1.11" "brace-expansion": "^1.1.7"
} }
}, },
"once": { "once": {
@ -113,7 +113,7 @@
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"requires": { "requires": {
"wrappy": "1.0.2" "wrappy": "1"
} }
}, },
"os-tmpdir": { "os-tmpdir": {
@ -141,12 +141,12 @@
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz",
"integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=",
"requires": { "requires": {
"core-util-is": "1.0.2", "core-util-is": "~1.0.0",
"inherits": "2.0.3", "inherits": "~2.0.1",
"isarray": "1.0.0", "isarray": "~1.0.0",
"process-nextick-args": "1.0.7", "process-nextick-args": "~1.0.6",
"string_decoder": "0.10.31", "string_decoder": "~0.10.x",
"util-deprecate": "1.0.2" "util-deprecate": "~1.0.1"
} }
}, },
"rimraf": { "rimraf": {
@ -154,7 +154,7 @@
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
"requires": { "requires": {
"glob": "7.1.3" "glob": "^7.1.3"
} }
}, },
"sax": { "sax": {
@ -167,10 +167,10 @@
"resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.1.tgz", "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.0.0-alpha.1.tgz",
"integrity": "sha512-z88rdjHAv3jmTZ7KSGUkTvo4rGzcDGMq0oXWHNIDK96Gs31JKVdu9+FMtT4KBrVoibg8dUicJDok6GnqqttO5Q==", "integrity": "sha512-z88rdjHAv3jmTZ7KSGUkTvo4rGzcDGMq0oXWHNIDK96Gs31JKVdu9+FMtT4KBrVoibg8dUicJDok6GnqqttO5Q==",
"requires": { "requires": {
"jszip": "3.1.5", "jszip": "^3.1.3",
"rimraf": "2.6.3", "rimraf": "^2.5.4",
"tmp": "0.0.30", "tmp": "0.0.30",
"xml2js": "0.4.19" "xml2js": "^0.4.17"
} }
}, },
"string_decoder": { "string_decoder": {
@ -183,7 +183,7 @@
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.30.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.30.tgz",
"integrity": "sha1-ckGdSovn1s51FI/YsyTlk6cRwu0=", "integrity": "sha1-ckGdSovn1s51FI/YsyTlk6cRwu0=",
"requires": { "requires": {
"os-tmpdir": "1.0.2" "os-tmpdir": "~1.0.1"
} }
}, },
"util-deprecate": { "util-deprecate": {
@ -201,8 +201,8 @@
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz",
"integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==",
"requires": { "requires": {
"sax": "1.2.4", "sax": ">=0.6.0",
"xmlbuilder": "9.0.7" "xmlbuilder": "~9.0.1"
} }
}, },
"xmlbuilder": { "xmlbuilder": {