Commit 16552081 authored by wangmingming's avatar wangmingming

111

parent e77b7743
......@@ -14,6 +14,112 @@ from pymongo import MongoClient
from loguru import logger
def get_random_location():
t1 = '''var _hostname, _origin,_host,_protocol,_port,_pathname,_search,_hash;
Object.defineProperties(location, {'''
t2 = [
''' href: {
value: 'https://www.southwest.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.southwest.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.southwest.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
def md5(text):
......@@ -21,30 +127,20 @@ def md5(text):
m.update(text.encode())
return m.hexdigest()
# 连接MongoDB数据库
client = MongoClient('mongodb://lcc-spider:JIUsfhiad&^@18.144.59.80:27017/?authSource=admin&directConnection=true')
db = client.env
# 查询所有文档
# result = db.env_shape.find({'env.funcs' :{'$ne': None}})
# data = {str(x['_id']): x['env'] for x in result}
# print(result)
# with open('env.json', 'w', encoding='utf-8') as f:
# f.write(json.dumps(data))
if platform.uname().system != 'Darwin':
# , 'success': {'$gte': 30}
# , 'env.navigatorparams.useragent': {'$regex': 'iPhone'}
result = db.env_shape.find({'env.funcs' :{'$ne': None}})
data = {str(x['_id']): x['env'] for x in result}
print(result)
with open('env.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(data))
result = db.env_shape.find({'env.funcs' :{'$ne': None}})
data = {str(x['_id']): x['env'] for x in result}
print(result)
with open('env.json', 'w', encoding='utf-8') as f:
f.write(json.dumps(data))
with open('env.json', 'r', encoding='utf-8') as f:
data = json.loads(f.read())
envs = data.keys()
# session = requests.session()
headers = {
"authority": "www.southwest.com",
......@@ -63,13 +159,14 @@ headers = {
}
# tlss = [ 'chrome_103', 'chrome_104', 'chrome_105', 'chrome_106',
# 'firefox_102', 'firefox_104'
# Opera --> opera_89, opera_90
# 'safari_15_3', 'safari_15_6_1', 'safari_16_0',
# 'safari_ios_15_5', 'safari_ios_15_6', 'safari_ios_16_0',
# 'safari_ios_15_6'
# ]
# Opera --> opera_89, opera_90
# 'safari_15_3', 'safari_15_6_1', 'safari_16_0',
# 'safari_ios_15_5', 'safari_ios_15_6', 'safari_ios_16_0',
# 'safari_ios_15_6'
# ]
success = 0
total = 0
while True:
# r = requests.get('http://ymx-lcc.unififi.com/header/task/pull/headerB6?brush_name=test')
# if r.json()['status'] != 0:
......@@ -77,16 +174,16 @@ while True:
# time.sleep(10)
# continue
logger.debug('开始刷值')
selectId = random.choice(list(envs))
lastHash = ''
usedTime = 10
success = 0
total = 0
code = open('src.js', 'r', encoding='utf-8').read()
# code1 = open('js_dom_run.js', 'r', encoding='utf-8').read()
code1 = open('js_dom_run.js', 'r', encoding='utf-8').read()
for i in range(30):
try:
# selectId = '55a8fe24a752595e774341d6'
selectId = random.choice(list(envs))
proxy = f'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@usa.rotating.proxyrack.net:{int(random.randint(10000, 11149))}'
# proxy = f'http://ynfflcc2023.hotmail.com:gdcfh9@69.30.227.194:{random.randint(20001, 20250)}'
# proxy = f'http://user-uni003-region-us-sessid-{random.randint(1000,5000)}-sesstime-5-keep-true:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'
......@@ -97,11 +194,11 @@ while True:
# proxy = requests.post('http://ymx-lcc.unififi.com/proxy/get-proxy', json={'name':"B6", 'type':'shopping'}).json()['url']
# proxy = f'http://ynfflcc2023.hotmail.com:gdcfh9@69.30.227.194:{random.randint(20001, 20250)}'
proxy1 = f'http://user-uni003-region-us-sessid-${random.randint(1000,5000)}-sesstime-5-keep-true:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'
proxy2 = f'http://uni00001_custom_zone_US_sid_67336718_time_5:q39CEBTs5A@us.foxyip.com:7778'
proxy1 = f'http://user-uni003-region-us-sessid-${random.randint(1000, 5000)}-sesstime-5-keep-true:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'
proxy2 = f'http://uni00001_custom_zone_US_sid_{random.randint(67336718, 67336918)}_time_5:q39CEBTs5A@us.foxyip.com:7778'
# proxy = f'http://unfflcc:76cc14-47b8dd-1f8ace-827836-0c740e@198.147.25.26:{int(random.randint(10000, 11149))}'
# proxy = 'http://user-unifflcc-region-us:q39CEBTs5A5YQXor@pr.roxlabs.cn:4600'
proxy = random.choice([proxy1, proxy])
proxy = random.choice([proxy, proxy1])
tlsV = f'chrome_{random.randint(105, 113)}'
tlsV = 'chrome_112'
session = tls_client.Session(tlsV)
......@@ -115,10 +212,10 @@ while True:
# 'https': 'http://127.0.0.1:7890',
# }
# selectId = 'a74b38e7115cf4d1b1f6976c'
c = session.get('https://www.southwest.com/assets/app/scripts/swa-common.js', insecure_skip_verify=True).text
m5 = md5(c)
if m5 != lastHash and usedTime > 5:
lastHash = m5
if usedTime > 10:
c = session.get('https://www.southwest.com/assets/app/scripts/swa-common.js',
insecure_skip_verify=True).text
usedTime = 0
logger.debug('js变化')
token = re.findall('nt"\),\["(.+?)",', c)[0]
......@@ -127,11 +224,11 @@ while True:
# 'update_time': int(time.time() * 1000)
# })
code = open('src.js', 'r', encoding='utf-8').read()
# code1 = open('js_dom_run.js', 'r', encoding='utf-8').read()
code1 = open('js_dom_run.js', 'r', encoding='utf-8').read()
with open('src_run1.js', 'w', encoding='utf-8') as f:
f.write(code + '\n\n' + c)
f.write(code + '\n\n' + get_random_location() + ';;' + c)
# with open('js_dom_run1.js', 'w', encoding='utf-8') as f:
# f.write(code1 + '\n\n' + c)
# f.write(code1 + '\n\n' +get_random_location() +';;'+ + c)
t1 = time.time()
# token = list(db.token_shape.aggregate( [ { '$sample': { 'size': 1 } } ] ))[0]['_id']
# r = requests.get('http://127.0.0.1:5000/getinfo').json()['message']
......@@ -157,7 +254,8 @@ while True:
print(r)
headers.update(r)
# headers = r
logger.info(f"success:{success} total:{total} {(time.time() - t1) *1000:.3f}ms {len(headers['ee30zvqlwf-a'])} {selectId} {headers['user-agent']}")
logger.info(
f"success:{success} total:{total} {(time.time() - t1) * 1000:.3f}ms {len(headers['EE30zvQLWf-a'])} {selectId} {headers['user-agent']}")
logger.info(f"success:{success} proxy: {proxy} token: {token}")
url = "https://www.southwest.com/api/air-booking/v1/air-booking/page/air/booking/shopping"
data = {
......@@ -191,7 +289,7 @@ while True:
# ))
# status_code = response.json()['status_code']
logger.info(f'tls:{tlsV} proxy:{proxy} res:: {status_code}')
# total += 1
total += 1
print(response.text)
if status_code != 403:
# res = db.env_shape.update_one(
......@@ -221,4 +319,3 @@ while True:
# time.sleep(3)
except Exception as e:
print(e)
time.sleep(10)
This source diff could not be displayed because it is too large. You can view the blob instead.
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