-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bump origin IP on nhentai (#23)
* NHENTAI_IP_4 * adjust modifier * improve tests * bump deps * revert breaking changes
- Loading branch information
Showing
4 changed files
with
27 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
import c from "../src/utils/options"; | ||
import p from "phin"; | ||
import { name, version } from "../package.json"; | ||
|
||
for (const url of | ||
[c.HENTAIFOX, c.PURURIN, c.HENTAI2READ, c.SIMPLY_HENTAI, | ||
c.SIMPLY_HENTAI_PROXIFIED, c.NHENTAI, c.NHENTAI_IP_3, c.ASMHENTAI]) { | ||
p({ url }).then(res => { | ||
if (res.statusCode !== 200) { | ||
console.log(`${url} is not available, status code: ${res.statusCode}`); | ||
function getKeyByValue(data: any, value: string) { | ||
return Object.keys(data).find(key => data[key] === value); | ||
} | ||
|
||
for (const url of | ||
[ | ||
c.NHENTAI_IP_4, | ||
c.HENTAIFOX, | ||
c.PURURIN, | ||
c.ASMHENTAI, | ||
c.SIMPLY_HENTAI_PROXIFIED, | ||
c.HENTAI2READ, | ||
c.THREEHENTAI | ||
]) { | ||
p({ | ||
url: url, | ||
headers: { | ||
"User-Agent": `${name}/${version} Node.js/16.9.1`, | ||
} | ||
}).then(res => { | ||
if (res.statusCode !== 200 && res.statusCode !== 308 && res.statusCode !== 301) { | ||
throw new Error(`${url} of ${getKeyByValue(c, url)} is not available, status: ${res.statusCode}, couldn't be scrape`); | ||
} | ||
else { | ||
console.log(`${url} is available, can be scraped`); | ||
console.log(`${url} is available status: ${res.statusCode}, could be scrape`); | ||
} | ||
}); | ||
} |