Commit a6a46077 authored by wang's avatar wang

ws 测试

parent e58ecc06
......@@ -16,113 +16,6 @@ import hashlib
from pymongo import MongoClient
from loguru import logger
def get_random_location():
return ''
t1 = '''var _hostname, _origin,_host,_protocol,_port,_pathname,_search,_hash;
Object.defineProperties(location, {'''
t2 = [
''' href: {
value: 'https://www.westjet.com/air/booking/index.html?adultPassengersCount=1&adultsCount=1&departureDate=2023-07-13&departureTimeOfDay=ALL_DAY&destinationAirportCode=BOS&fareType=POINTS&int=HOMEQBOMAIR&originationAirportCode=LAS&passengerType=ADULT&reset=true&returnDate=&returnTimeOfDay=ALL_DAY&tripType=oneway&validate=true',
enumerable: true
},
''',
'''ancestorOrigins: {
get: v_saf(function ancestorOrigins() {
return new DOMStringList()
}),
enumerable: true,
configurable: false
},''',
''' hostname: {set: function(arg){_hostname = arg}, get:function(){return _hostname}, enumerable:true},''',
'''reload: {
value: v_saf(function reload() {
}),
enumerable: true,
},''',
'''protocol: {set: function(arg){_protocol = arg}, get:function(){return _protocol}, enumerable:true},''',
'''host: {set: function(arg){_hostname = arg}, get:function(){return _hostname}, enumerable:true},''',
''' port: {set: function(arg){_port = arg}, get:function(){return _port}, enumerable:true},''',
''' hash: {set: function(arg){_hash = arg}, get:function(){return _hash}, enumerable:true},''',
''' pathname: {set: function(arg){_pathname = arg}, get:function(){return _pathname}, enumerable:true},''',
'''origin: {set: function(arg){_origin = arg}, get:function(){return _origin}, enumerable:true},''',
'''search: {set: function(arg){_pathname = arg}, get:function(){return _pathname}, enumerable:true},''',
'''assign: {
value: v_saf(function assign() {
}),
enumerable: true,
},''',
'''toString: {
value: v_saf(function toString() {
return ''
}),
enumerable: true,
},''',
'''replace: {
value: v_saf(function replace() {
}),
enumerable: true,
},'''
]
random.shuffle(t2)
# print(t2)
r = '''location.href = 'https://www.westjet.com/air/booking/index.html?adultPassengersCount=1&adultsCount=1&departureDate=2023-07-13&departureTimeOfDay=ALL_DAY&destinationAirportCode=BOS&fareType=POINTS&int=HOMEQBOMAIR&originationAirportCode=LAS&passengerType=ADULT&reset=true&returnDate=&returnTimeOfDay=ALL_DAY&tripType=oneway&validate=true'
function set_href(v, href){
href = href.trim()
v_console_log(` href[set]:`, JSON.stringify(href))
if (href.startsWith("http://") || href.startsWith("https://")) {/*ok*/
} else if (href.startsWith("//")) {
href = (v.protocol ? v.protocol : 'http:') + href
} else {
href = v.protocol + "//" + v.host + (v.port ? ":" + v.port : "") + '/' + ((href[0] == '/') ? href.slice(1) : href)
}
var a = href.match(/([^:]+:)\/\/([^/:?#]+):?(\d+)?([^?#]*)?(\?[^#]*)?(#.*)?/);
v.protocol = a[1] ? a[1] : "";
v.host = a[2] ? a[2] : "";
v.port = a[3] ? a[3] : "";
v.pathname = a[4] ? a[4] : "";
v.search = a[5] ? a[5] : "";
v.hash = a[6] ? a[6] : "";
v.hostname = v.host;
v.origin = v.protocol + "//" + v.host + (v.port ? ":" + v.port : "");
}
// 'valueOf,ancestorOrigins,href,origin,protocol,host,hostname,port,pathname,search,hash,assign,reload,replace,toString'
set_href(location, 'https://www.westjet.com/air/booking/index.html?adultPassengersCount=1&adultsCount=1&departureDate=2023-07-13&departureTimeOfDay=ALL_DAY&destinationAirportCode=BOS&fareType=POINTS&int=HOMEQBOMAIR&originationAirportCode=LAS&passengerType=ADULT&reset=true&returnDate=&returnTimeOfDay=ALL_DAY&tripType=oneway&validate=true')
window.location = location
// window.location = new Proxy(location, {
// get(target, p, receiver) {
// console.log('locaiton get', p)
// return Reflect.get(target, p, receiver)
// },
// has(target, p) {
// let res = Reflect.has(target, p);
// console.log('locaiton has', p, res)
// return res;
// },
// getOwnPropertyDescriptor(target, p) {
// let res = Reflect.getOwnPropertyDescriptor(target, p);
//
// console.log('locaiton getOwnPropertyDescriptor', p, res)
// return res;
// }
// })
origin = location.origin
'''
return t1 + '\n' + '\n'.join(t2) + '})\n' + r
work_dir = os.environ.get('work_dir')
def get_proxy():
get_proxy_url = 'http://aws-lcc.unififi.com/proxy/get-proxy'
......@@ -137,7 +30,7 @@ def md5(text):
return m.hexdigest()
# 连接MongoDB数据库
client = MongoClient('mongodb://lcc-spider:JIUsfhiad&^@54.183.159.9:27017/?authSource=admin&directConnection=true')
client = MongoClient('mongodb://lcc-spider:JIUsfhiad&^@13.52.65.111:27017/?authSource=admin&directConnection=true')
db = client.env
# 查询所有文档
#platform.uname().system != 'Darwin' and not
......
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