Commit 5778036d authored by wang's avatar wang

f9

parent fff00571
...@@ -3,7 +3,9 @@ import {bl, genUuid, ht, ie, Ol, randint, se} from "./utils.js" ...@@ -3,7 +3,9 @@ import {bl, genUuid, ht, ie, Ol, randint, se} from "./utils.js"
import axios from "axios"; import axios from "axios";
import {PxEnv} from './px.js' import {PxEnv} from './px.js'
import {MongoClient} from "mongodb"; import {MongoClient} from "mongodb";
import * as fs from "fs";
let ENVS = JSON.parse(fs.readFileSync('./env.json', 'utf-8').toString())
let keys = Object.keys(ENVS);
const uri = "mongodb://lcc-spider:JIUsfhiad&^@54.183.159.9:27017/?authSource=admin&directConnection=true"; const uri = "mongodb://lcc-spider:JIUsfhiad&^@54.183.159.9:27017/?authSource=admin&directConnection=true";
const client = new MongoClient(uri); const client = new MongoClient(uri);
log4js.levels.INFO.colour = 'white'; log4js.levels.INFO.colour = 'white';
...@@ -95,21 +97,21 @@ class PxBypass { ...@@ -95,21 +97,21 @@ class PxBypass {
async initMongo() { async initMongo() {
this.log.info("init mongo 获取环境数据") this.log.info("init mongo 获取环境数据")
const database = client.db("env"); // const database = client.db("env");
const movies = database.collection("env_shape"); // const movies = database.collection("env_shape");
// Query for a movie that has the title 'The Room' // // Query for a movie that has the title 'The Room'
const query = { // const query = {
'env.funcs': {$ne: null}, // 'env.funcs': {$ne: null},
}; // };
//
// Execute query // // Execute query
const movie = await movies.aggregate([ // const movie = await movies.aggregate([
{$match: query}, // {$match: query},
{$sample: {size: 1}} // {$sample: {size: 1}}
]) // ])
let res = await movie.toArray() // let res = await movie.toArray()
this.env = res[0].env // this.env = res[0].env
this.env = ENVS[keys[randint(0, keys.length - 1)]]
this.ua = this.env.navigatorparams.useragent this.ua = this.env.navigatorparams.useragent
this.log.info('ua', this.ua) this.log.info('ua', this.ua)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment