Jump to content

QuangBlue

Members
  • Số lượng nội dung

    19
  • Đã tham gia

  • Lần ghé thăm cuối

Cộng đồng

1 Neutral

1 Người theo dõi

Khách vừa ghé thăm

Khách vừa ghé thăm đã bị tắt và không được hiển thị tới những người dùng khác.

  1. Dạ vấn đề là em hiểu thêm 4 cái biến đó vào cái def đó. Nhưng cơ bản là e ko có căn bản JS cho nên đọc không hiểu gì ráo ... bác có thể giúp e chuyển quá python không . :(
  2. Em thề là em bỏ ra 2 tuần học JS để chỉ đọc cái này thôi , mà đến hôm nay bỏ cuộc luôn .... có anh chị em nào hỗ trợ e chuyển nó về python ko ạ T_T. Tính phí cũng dc. Trực tiếp zalo e dc ko. :( 0908990094 đúng oải luôn huhu
  3. @Thiên Chi Kiều Nữ @Công Dũng function(e, t, n) { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), t.getSecurityHash = function(e, t) { var n = t.url , r = t.method , c = t.token , u = t.ctoken , l = function(e) { return "live" === (0, o.getRuntimeServer)() ? i[e] : s[e] }(e); switch (e) { case 1: return function(e, t) { return (0, a.default)(e + t).toString() }(n, l); case 2: return function(e, t, n) { return (0, a.default)(e + t + n).toString() }(n, l, r); case 3: return function(e, t, n) { return (0, a.default)(e + t + n).toString() }(n, l, c); case 4: return function(e, t, n) { return (0, a.default)(e + t + n).toString() }(n, l, u); default: return "" } } ; var r, a = (r = n(54)) && r.__esModule ? r : { default: r }, o = n(4), s = { 1: "70c74f4e-dcda-483e-826b-19dd2c42e799", 2: "29ffec18-c614-4645-8f1c-686e22d2e26a", 3: "04229e76-1ba3-4ac9-8a4e-68d46a3881a2", 4: "a3769a87-35cf-45e9-a5a7-2b4016c52e92" }, i = { 1: "396c15ad-6d3e-4018-98be-cef58cb45cd0", 2: "607c871d-b766-4c6f-ba89-b6c6ca32b156", 3: "42990074-9a73-4459-b749-f3110d222a72", 4: "5702b6f3-62a3-44d2-abe8-fece100a8bf4" } } cái getSecurityHash mình thấy có chỗ này. Mọi người igúp mình với, không học JS nên ngu quá T_T
  4. Mình tìm thấy đoạn này trong JS của shopee : return new Promise((function(e, a) { if (void 0 !== x && parseInt(x) <= 0 || void 0 !== C && parseInt(C) <= 0) { var d = [b, C, y, x, _].filter((function(e) { return e } )).join("/"); return f.reportException(d + " parameter exception: " + C + "/" + x), void a(new Error) } var A = z.includes("/webchat/api") ? { "x-v": w || "", "x-s": (0, p.getSecurityHash)(w, { url: F, method: S, token: k.Authorization, ctoken: n || "" }) } : {} , h = { method: S, headers: r({}, k, A), body: R }; M && (h.credentials = M), (0, o.default)(z, h).then((function(e) { switch (200 === (B = e.status) && (T = parseInt(e.headers.get("total")), P = parseInt(e.headers.get("per-page"))), B) { case 204: return null; case 404: return { message: "Resource not found" }; case 500: return { message: "Internal server error." }; case 502: return { message: "Bad Gateway" }; default: return e.json() } } )).then((function(n) { var r, o, d, p = Date.now() - D; if ("read" === y && (0, u.collectAsyncTask)(u.ReportPoint.READ_API, p), void 0 === x && void 0 !== y && ("messages" === y && U.indexOf("shop_id") < 0 ? (L = JSON.parse(R).request_id, (0, l.setItem)(L, D), (0, u.collectAsyncTask)(u.ReportPoint.MESSAGE_API, p)) : u.ReportPoint[y.toUpperCase()] && (0, u.collectAsyncTask)(u.ReportPoint[y.toUpperCase()], p)), 200 === B ? e(n instanceof Array ? (r = { total: T, perPage: P }, o = y, d = n.map(N), o in r ? Object.defineProperty(r, o, { value: d, enumerable: !0, configurable: !0, writable: !0 }) : r[o] = d, r) : N(n)) : 204 === B && e(), (0, i.isError)(B)) { var A = t || [b, C, y, x, _].filter((function(e) { return e } )).join("/"); if (400 !== B && 404 !== B || (f.setTag("API Request Error", A), f.reportException(new ((0, i.HTTPError)(B))(JSON.stringify({ body: n, status: B })))), [429, 491, 493].includes(B)) { var h = new ((0, i.HTTPError)(B))(n); a(h) } else if (401 === B) if (y.includes("login")) { var g = new ((0, i.HTTPError)(B))(n.message,n.errors || n.error_code || n.errcode,n.data); a(g) } else s.store.dispatch((0, c.handle401ErrorRequested)({ resource: y })); else { var m = new ((0, i.HTTPError)(B))(n.message,n.errors || n.error_code || n.errcode,n.data); a(m) } } } mà thề là đang học python thôi. cái JS này .... :( mọi người giúp mình với.
  5. Lấy từ https://banhang.shopee.vn/webchat/api/v1.2/login?_uid={uid}&csrf_token={csrf_token}' Mỵ xem giúp với, hix bí cả tuần ko làm được gì T_T
  6. def chat(uid,csrf_token_30,new_auth,coo): url = f'https://banhang.shopee.vn/webchat/api/v1.2/messages?_uid={uid}&csrf_token={csrf_token_30}' # ĐOẠN NÀY 'authorization' LẤY TỪ REQUEST TỚI URL LOGIN headers = { 'accept' : '*/*', 'accept-encoding' : 'gzip, deflate, br', 'authorization' : f'Bearer {new_auth}', # ĐOẠN MỴ NÓI NÈ PHẢI KO ? 'content-type' : 'text/plain;charset=UTF-8', 'referer' : 'https://banhang.shopee.vn/webchat/conversations', 'pragma' : 'no-cache', 'user-agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66' } # ĐOẠN NÀY LÀ ADD THÊM CÁI CTONKEN VÀO COOKIE g = requests.cookies.RequestsCookieJar() g.set(domain='.shopee.vn',name='CTOKEN',value=csrf_token_30) coo.update(g) cookies = coo # ĐOẠN NÀY LÀ DATA PAYLOAD data = { "request_id":"23423427", "to_id":230448022, "type":"text", "content":{"text":"Dạ cảm ơn bạn rất nhiều nè"}, "chat_send_option":{"force_send_cancel_order_warning":False,"comply_cancel_order_warning":False}} i = requests.post(url, headers=headers, cookies=cookies, data=data)
  7. import requests, json, hashlib, random def encrypt_SHA256(password): sha_signature = \ hashlib.sha256((hashlib.md5(password.encode()).hexdigest()).encode()).hexdigest() return sha_signature def csrf_token(): character='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' return ''.join((random.choice(character) for i in range(22))) + '%3D%3D' def csrftoken(length=32): character='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' return ''.join((random.choice(character) for i in range(8))) + '-' + ''.join((random.choice(character) for i in range(4))) + '-' + ''.join((random.choice(character) for i in range(4))) + '-' + ''.join((random.choice(character) for i in range(4))) + '-' + ''.join((random.choice(character) for i in range(12))) def sign_in_shopee(): q = csrftoken() id_sp = "xxxxxxx" pass_sh = encrypt_SHA256("xxxxxxx") session = requests.Session() payload = { 'phone' : id_sp, 'password_hash': pass_sh, 'remember': 'false', } url='https://banhang.shopee.vn/api/v2/login/?SPC_CDS=' + q + '&SPC_CDS_VER=2' response = session.request("POST",url, data = payload) if response.status_code != 200 : print (f'Đăng nhập thất bại tài khoản {id_sp}. Lỗi ' + str(response.status_code)) exit() return response.cookies def get_auth(cookies): url = 'https://banhang.shopee.vn/webchat/api/v1.2/mini/login?source=sc&_v=4.8.0&_api_source=sc' request_post = requests.post(url,cookies=cookies) results = request_post.json() return results def new_cookie(coo,csrf_token): g = requests.cookies.RequestsCookieJar() g.set(domain='.shopee.vn',name='CTOKEN',value=csrf_token) coo.update(g) x = coo return x def new_ctoken(auth_code,csrf_token,new_cookie,uid): headers ={ 'authorization' : f'Bearer {auth_code}' } cookies = new_cookie url = f'https://banhang.shopee.vn/webchat/api/v1.2/login?_uid={uid}&csrf_token={csrf_token}' x = requests.post(url,headers=headers,cookies=cookies) k = dict(x.cookies.iteritems()) k['token'] = x.json()['token'] return k def chat(uid,csrf_token_30,new_auth,coo): url = f'https://banhang.shopee.vn/webchat/api/v1.2/messages?_uid={uid}&csrf_token={csrf_token_30}' headers = { 'accept' : '*/*', 'accept-encoding' : 'gzip, deflate, br', 'authorization' : f'Bearer {new_auth}', 'content-type' : 'text/plain;charset=UTF-8', 'referer' : 'https://banhang.shopee.vn/webchat/conversations', 'pragma' : 'no-cache', 'user-agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66' } g = requests.cookies.RequestsCookieJar() g.set(domain='.shopee.vn',name='CTOKEN',value=csrf_token_30) coo.update(g) cookies = coo data = { "request_id":"23423427", "to_id":230448022, "type":"text", "content":{"text":"Dạ cảm ơn bạn rất nhiều nè"}, "chat_send_option":{"force_send_cancel_order_warning":False,"comply_cancel_order_warning":False}} i = requests.post(url, headers=headers, cookies=cookies, data=data) if __name__ == "__main__": cookies = sign_in_shopee() auth_code = get_auth(cookies)['token'] csrf_token = csrf_token() new_cookie = new_cookie(cookies,csrf_token) uid = get_auth(cookies)['user']['uid'] csrf_token_30 = new_ctoken(auth_code,csrf_token,new_cookie,uid)['CTOKEN'] new_auth = new_ctoken(auth_code,csrf_token,new_cookie,uid)['token'] chat(uid,csrf_token_30,new_auth,cookies)
  8. Có bác nào chuyển đoạn code này sang python đc không ạ :D. Em tay ngang đọc không hiểu được huhu
  9. QuangBlue

    Chat trong Shopee

    Mình đang tìm cách để trả lời khách hàng khi có đơn hàng. Mình không thể nào Request để đẩy Chat lên được. Nghe nói chat shopee sử dụng Websocket thì làm sao tạo request bằng python được ạ. Mong được mọi người giúp đỡ
×
×
  • Create New...