title | tags | parameters | reference | |||
---|---|---|---|---|---|---|
リンク切れ |
|
|
Last active
December 19, 2021 06:30
-
-
Save freddiefujiwara/9fbc068c95e344d68b33e08001b0d9a9 to your computer and use it in GitHub Desktop.
dogbot-find-brokenlinks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
I | |
} = inject(); | |
module.exports = { | |
async run() { | |
const fs = require('fs'); | |
const os = require('os'); | |
for await (url of fs.readFileSync(process.env.URLS) | |
.toString() | |
.split(os.EOL)) { | |
if (!url.match(/^http/)) { | |
continue; | |
} | |
I.amOnPage(url); | |
const elem = await I.grabNumberOfVisibleElements(locate('a')); | |
for await (i of [...Array(elem).keys()]) { | |
const target = locate('a').at(i + 1); | |
const link = await I.grabAttributeFrom(target, 'href'); | |
if (link.match(/^javascript/)) { | |
continue; | |
} | |
I.clickIfVisible(target); | |
I.seeElement('body'); | |
I.amOnPage(url); | |
} | |
I.say(url); | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment