Commit 23f309d1 authored by wang's avatar wang

ws 测试

parent 85569cbd
......@@ -5,6 +5,8 @@ import re
import subprocess
import time
import os
import traceback
import loguru
import requests
import json
......@@ -234,6 +236,9 @@ while True:
# 'http': 'http://127.0.0.1:7890',
# 'https': 'http://127.0.0.1:7890',
# }
selectId = random.choice(list(envs))
# selectId = '197d94c3099d110aef4e0a52'
if usedTime > 10:
......@@ -244,11 +249,13 @@ while True:
))
c1 = response.json()['text']
m5 = md5(c1)
ck = response.json()['cookies']['z0t0U8fo']
if m5 != lastHash:
lastHash = m5
usedTime = 0
logger.debug('js变化')
js_uri = re.findall('(https://www\.westjet\.com/resources/.+?)"', c1)[0]
logger.info(f'get {js_uri}' )
response = requests.post('http://52.52.23.116/tls/forward',
json=dict(url=js_uri,
headers=headers, method="GET", proxy=proxy, debug=True
......@@ -261,16 +268,11 @@ while True:
+
';;;\n\n' + '''
var xhr = new XMLHttpRequest();
//xhr.open('POST', "https://www.westjet.com/api/air-booking/v1/air-booking/page/air/booking/shopping", false);
//xhr.send(`{"tripType":"oneWay","from":"ZLA","to":"NAS","depart":"2023-04-11","cabin":"economy","refundable":false,"dates":{"before":"3","after":"3"},"pax":{"ADT":1,"CHD":0,"INF":0,"UNN":0},"redempoint":false,"pointsBreakup":{"option":"","value":0},"isMultiCity":false}`)
//xhr.setRequestHeader('user-agent', ENV.navigatorparams.useragent)
//print(JSON.stringify(xhr.headers))
//_process.exit(0)
setTimeout(r=> {
var
xhr = new
XMLHttpRequest();
xhr.open('POST', "https://apiw.westjet.com/ecomm/booktrip/flight-search-api/v1", false);
xhr.send(`{"tripType": "oneWay", "from": "ZLA", "to": "NAS", "depart": "2023-04-11",
"cabin": "economy", "refundable": false, "dates": {"before": "3", "after": "3"},
......@@ -298,13 +300,14 @@ setTimeout(r=> {
# p = subprocess.Popen(['node', 'js_dom_run1.js', selectId, '11'], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
# p = subprocess.Popen(['node', 'src_run_chrome_105.js', selectId, '11', token], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
# p = subprocess.Popen(['node', 'src_run_company_chrome.js', selectId, '11', token], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
p = subprocess.Popen(['node', 'src_run3.js', selectId, '11', token, proxy], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
p = subprocess.Popen(['node', 'src_run3.js', selectId,f'z0t0U8fo={ck}', '11', token, proxy], stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, err = p.communicate(timeout=30)
tmp = ''
if p.returncode == 0:
tmp = output.decode().split('\n')[-2]
else:
traceback.print_exc()
raise Exception(selectId)
r: dict = json.loads(tmp)
# res = db.env_shape.update_one(
......@@ -395,5 +398,6 @@ setTimeout(r=> {
logger.success(f'添加成功 {success}')
# time.sleep(3)
except Exception as e:
traceback.print_exc()
print(e)
time.sleep(1)
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