amrizal15 0 Đã viết 26/12/2020 Hi i'm new member and i'm interested with discussion that this forum have and i learn many knowledge from it. i just want to ask, i try to login with python request and i got this message {"version":"0075c2569e70b86c971eb1a29b9a1265","data":null,"error_msg":null,"error":1} i also test with status_code and that give number 200 that mean ok right ? so what the problem with my code? thanks before code: import requests import random import hashlib def random_str(length): character = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' return ''.join((random.choice(character) for i in range ( length ))) def encrypt_pass(password): sha_signature = \ hashlib.sha256((hashlib.md5(password.encode()).hexdigest()).encode()).hexdigest() return sha_signature def main(): username = 'sp_user' password = 'sp_pass' r = requests.Session() response = r.get( 'https://shopee.vn/buyer/login' ) csrftoken_gen = random_str( 32 ) cookie_string = ";" .join([ str(x) + "=" + str(y) for x , y in response.cookies.get_dict().items()]) headers = { 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.cd36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' , 'referer' : 'https://shopee.vn' , 'x-csrftoken' : csrftoken_gen , 'x-requested-with' : 'XMLHttpRequest' , 'cookie' : "csrftoken=" + csrftoken_gen + "; " + cookie_string + "SPC_CDS=" + "1" } url = "https://shopee.vn/api/v2/authentication/login" payload = { 'username':username , 'password': encrypt_pass(password), 'support_whats_app': 'true',} response = r.request("POST" , url ,headers=headers,data='{"username":"' + username + '","password":"' + encrypt_pass(password) + '","support_whats_app":true}' ) print (response.text) res = r.request("GET" , "https://shopee.vn/api/v2/user/profile/get/") print(res.content) if __name__ == '__main__' : main() Chia sẻ bài đăng này Link tới bài viết Share on other sites
2 Thiên Chi Kiều Nữ 953 Đã viết 26/12/2020 6 hours ago, amrizal15 said: Hi i'm new member and i'm interested with discussion that this forum have and i learn many knowledge from it. i just want to ask, i try to login with python request and i got this message {"version":"0075c2569e70b86c971eb1a29b9a1265","data":null,"error_msg":null,"error":1} i also test with status_code and that give number 200 that mean ok right ? so what the problem with my code? thanks before code: import requests import random import hashlib def random_str(length): character = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' return ''.join((random.choice(character) for i in range ( length ))) def encrypt_pass(password): sha_signature = \ hashlib.sha256((hashlib.md5(password.encode()).hexdigest()).encode()).hexdigest() return sha_signature def main(): username = 'sp_user' password = 'sp_pass' r = requests.Session() response = r.get( 'https://shopee.vn/buyer/login' ) csrftoken_gen = random_str( 32 ) cookie_string = ";" .join([ str(x) + "=" + str(y) for x , y in response.cookies.get_dict().items()]) headers = { 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.cd36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36' , 'referer' : 'https://shopee.vn' , 'x-csrftoken' : csrftoken_gen , 'x-requested-with' : 'XMLHttpRequest' , 'cookie' : "csrftoken=" + csrftoken_gen + "; " + cookie_string + "SPC_CDS=" + "1" } url = "https://shopee.vn/api/v2/authentication/login" payload = { 'username':username , 'password': encrypt_pass(password), 'support_whats_app': 'true',} response = r.request("POST" , url ,headers=headers,data='{"username":"' + username + '","password":"' + encrypt_pass(password) + '","support_whats_app":true}' ) print (response.text) res = r.request("GET" , "https://shopee.vn/api/v2/user/profile/get/") print(res.content) if __name__ == '__main__' : main() Hi brother. here your success code for login ver2 :) .. please check your code import requests import random import hashlib import json uname = '' upass_encrypted = '' csrf_token = 'tiD9H2iSvcx6a0ZfGtt2xsdY97wIAMhy' rq = requests.Session() rq.cookies.update({"csrftoken": csrf_token}) rq.headers.update({ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36", "referer": "https://shopee.vn/", "x-api-source": "pc", "x-shopee-language": "vi", "x-requested-with": "XMLHttpRequest", "x-csrftoken": csrf_token }) rs = rq.get('https://shopee.vn/buyer/login') data = {"username": uname, "password": upass_encrypted, "support_whats_app": True} rs = rq.post('https://shopee.vn/api/v2/authentication/login/', data=json.dumps(data)) rs = rq.get('https://shopee.vn/api/v2/user/profile/get/') print(rs.json()) 1 Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 amrizal15 0 Đã viết 27/12/2020 (edited) 17 hours ago, Thiên Chi Kiều Nữ said: Hi brother. here your success code for login ver2 :) .. please check your code code You're life saver!!! i'm thinking so hard and dont know how to solve and you solved it like a charm! thank you master now i succesfully login and add to cart, but then i try to post data to checkout but get error 406, in https://shopee.vn/api/v4/cart/checkout i see some req payload data like this : {"selected_shop_order_ids":[{"shopid":350605150,"item_briefs":[{"itemid":5467792469,"modelid":90152275157,"item_group_id":null,"applied_promotion_id":1223949055,"offerid":null,"price":22000000000,"quantity":1,"is_add_on_sub_item":null,"add_on_deal_id":null,"status":1,"cart_item_change_time":1609056840}],"shop_vouchers":[]}],"platform_vouchers":[]}. Then i try to post that data with my code and got result 406, what problem from my code sir ? thanks before rq.cookies.update({"csrftoken": csrf_token}) sp_header2 = {'referer' : 'https://shopee.vn/cart/' , 'content-type' : 'application / json', 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36' , 'x-api-sourde' : 'pc', 'x-csrftoken' : csrf_token , 'x-requested-with' : 'XMLHttpRequest', 'x-shopee-language' : 'vi' } rq.headers.update(sp_header2) payload2= {"selected_shop_order_ids": [{"shopid":350605150, "item_briefs":[{"itemid":5467792469, "modelid":90152275157, "applied_promotion_id":1223949055, "price":22000000000, "quantity":1, "status":1, "cart_item_change_time":1609056662}], "shop_vouchers":[]}], "platform_vouchers":[]} response2 = rq.post('https://shopee.vn/api/v4/cart/checkout' , data=json.dumps(payload2)) print(response2) Edited 27/12/2020 by amrizal15 quote error Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Thiên Chi Kiều Nữ 953 Đã viết 27/12/2020 3 hours ago, amrizal15 said: You're life saver!!! i'm thinking so hard and dont know how to solve and you solved it like a charm! thank you master now i succesfully login and add to cart, but then i try to post data to checkout but get error 406, in https://shopee.vn/api/v4/cart/checkout i see some req payload data like this : {"selected_shop_order_ids":[{"shopid":350605150,"item_briefs":[{"itemid":5467792469,"modelid":90152275157,"item_group_id":null,"applied_promotion_id":1223949055,"offerid":null,"price":22000000000,"quantity":1,"is_add_on_sub_item":null,"add_on_deal_id":null,"status":1,"cart_item_change_time":1609056840}],"shop_vouchers":[]}],"platform_vouchers":[]}. Then i try to post that data with my code and got result 406, what problem from my code sir ? thanks before rq.cookies.update({"csrftoken": csrf_token}) sp_header2 = {'referer' : 'https://shopee.vn/cart/' , 'content-type' : 'application / json', 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36' , 'x-api-sourde' : 'pc', 'x-csrftoken' : csrf_token , 'x-requested-with' : 'XMLHttpRequest', 'x-shopee-language' : 'vi' } rq.headers.update(sp_header2) payload2= {"selected_shop_order_ids": [{"shopid":350605150, "item_briefs":[{"itemid":5467792469, "modelid":90152275157, "applied_promotion_id":1223949055, "price":22000000000, "quantity":1, "status":1, "cart_item_change_time":1609056662}], "shop_vouchers":[]}], "platform_vouchers":[]} response2 = rq.post('https://shopee.vn/api/v4/cart/checkout' , data=json.dumps(payload2)) print(response2) status code = 406 this mean : Quote 406 Not Acceptable — httpstatuses.com It's same your first code, maybe you wrong data post or header data do not enought ... i have never code check out before ... hihi Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Thiên Chi Kiều Nữ 953 Đã viết 28/12/2020 @amrizal15 here your code check out success : import requests import json sp_csrf_token = '' sp_cookie_dict = ... rq = requests.Session() rq.cookies.update(sp_cookie_dict) sp_header = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36', 'referer': 'https://shopee.vn/cart/', 'x-csrftoken': sp_csrf_token, 'x-requested-with': 'XMLHttpRequest', 'x-shopee-language': 'vi', 'x-api-source': 'pc', 'content-type': 'application/json', } rq.headers.update(sp_header) #Change data same data you see in your F12 tab NetWork #Data below in my F12 with another product. dataPost = { "selected_shop_order_ids": [{"shopid": 60920527, #change "item_briefs": [{"itemid": 3154739650, #change "modelid": 40225558391, #change "item_group_id": None, "applied_promotion_id": 1225874505, #change "offerid": None, "price": 27500000000, #change "quantity": 1, "is_add_on_sub_item": None, "add_on_deal_id": None, "status": 1, "cart_item_change_time": 1609126330}], #change "shop_vouchers": []} ], "platform_vouchers": [] } rs = rq.post('https://shopee.vn/api/v4/cart/checkout', data=json.dumps(dataPost)) print(rs.text) Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Bảo An 1 Đã viết 8/07/2021 On 26/12/2020 at 06:40, Thiên Chi Kiều Nữ said: Hi brother. here your success code for login ver2 :) .. please check your code import requests import random import hashlib import json uname = '' upass_encrypted = '' csrf_token = 'tiD9H2iSvcx6a0ZfGtt2xsdY97wIAMhy' rq = requests.Session() rq.cookies.update({"csrftoken": csrf_token}) rq.headers.update({ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36", "referer": "https://shopee.vn/", "x-api-source": "pc", "x-shopee-language": "vi", "x-requested-with": "XMLHttpRequest", "x-csrftoken": csrf_token }) rs = rq.get('https://shopee.vn/buyer/login') data = {"username": uname, "password": upass_encrypted, "support_whats_app": True} rs = rq.post('https://shopee.vn/api/v2/authentication/login/', data=json.dumps(data)) rs = rq.get('https://shopee.vn/api/v2/user/profile/get/') print(rs.json()) code còn xài được khum bạn? mình mò chạy thử mà nó báo lỗi " {'bff_meta': None, 'error': 19, 'error_msg': 'NOT_LOGIN', 'data': None} " là sao nhờ Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Thiên Chi Kiều Nữ 953 Đã viết 8/07/2021 5 giờ trước, Bảo An said: code còn xài được khum bạn? mình mò chạy thử mà nó báo lỗi " {'bff_meta': None, 'error': 19, 'error_msg': 'NOT_LOGIN', 'data': None} " là sao nhờ Not login kìa ..bạn kiểm tra lại thông số bạn nạp vào đúng chưa ? Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Bảo An 1 Đã viết 9/07/2021 import requests import random import hashlib import json def encrypt_SHA256(password): sha_signature = \ hashlib.sha256((hashlib.md5(password.encode()).hexdigest()).encode()).hexdigest() return sha_signature uname = 'blacksmoke2906' upass_encrypted = encrypt_SHA256("Kh290699"); csrf_token = 'tiD9H2iSvcx6a0ZfGtt2xsdY97wIAMhy' rq = requests.Session() rq.cookies.update({"csrftoken": csrf_token}) rq.headers.update({ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36", "referer": "https://shopee.vn/", "x-api-source": "pc", "x-shopee-language": "vi", "x-requested-with": "XMLHttpRequest", "x-csrftoken": csrf_token }) rs = rq.get('https://shopee.vn/buyer/login') data = {"username": uname, "password": upass_encrypted, "support_whats_app": True } print(rs) rs = rq.post('https://shopee.vn/api/v2/authentication/login/', data=json.dumps(data)) rs = rq.get('https://shopee.vn/api/v2/user/profile/get/') print(rs.json()) mình mã hóa mk r code y chang mà cứ báo lỗi á hong hiểu luôn Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Thiên Chi Kiều Nữ 953 Đã viết 9/07/2021 1 hour ago, Bảo An said: import requests import random import hashlib import json def encrypt_SHA256(password): sha_signature = \ hashlib.sha256((hashlib.md5(password.encode()).hexdigest()).encode()).hexdigest() return sha_signature uname = 'blacksmoke2906' upass_encrypted = encrypt_SHA256("Kh290699"); csrf_token = 'tiD9H2iSvcx6a0ZfGtt2xsdY97wIAMhy' rq = requests.Session() rq.cookies.update({"csrftoken": csrf_token}) rq.headers.update({ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36", "referer": "https://shopee.vn/", "x-api-source": "pc", "x-shopee-language": "vi", "x-requested-with": "XMLHttpRequest", "x-csrftoken": csrf_token }) rs = rq.get('https://shopee.vn/buyer/login') data = {"username": uname, "password": upass_encrypted, "support_whats_app": True } print(rs) rs = rq.post('https://shopee.vn/api/v2/authentication/login/', data=json.dumps(data)) rs = rq.get('https://shopee.vn/api/v2/user/profile/get/') print(rs.json()) mình mã hóa mk r code y chang mà cứ báo lỗi á hong hiểu luôn 1 là bạn bị sai pass, 2 là login của bạn có otp :| .. của mỵ tắt otp rồi nên ko có báo otp.. pass bạn đúng chứ ?? Chuẩn rồi... nick của bạn có OTP nhé...cần request thêm phát nữa 1 Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Đinh Vĩnh Khương 0 Đã viết 9/07/2021 (edited) . Edited 9/07/2021 by Đinh Vĩnh Khương Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Bảo An 1 Đã viết 9/07/2021 (edited) hèn chi mình mới tắt bên kênh người bán vẫn báo lỗi otp hihi tks chế mình vô đc r ^^ Edited 9/07/2021 by Bảo An 1 Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 vominhhuyVAC 0 Đã viết 9/07/2021 Thím nào convert sang c# rồi cho e xin với. Thanks! Chia sẻ bài đăng này Link tới bài viết Share on other sites
0 Thiên Chi Kiều Nữ 953 Đã viết 9/07/2021 1 hour ago, vominhhuyVAC said: Thím nào convert sang c# rồi cho e xin với. Thanks! không comment vào câu hỏi người khác bạn nhé. Có thể tạo topic mới bên C# cho đúng ngôn ngữ. C# mỵ đã làm rồi, bạn vào link này tham khảo : 1 Chia sẻ bài đăng này Link tới bài viết Share on other sites
Hi i'm new member and i'm interested with discussion that this forum have and i learn many knowledge from it.
i just want to ask, i try to login with python request and i got this message
{"version":"0075c2569e70b86c971eb1a29b9a1265","data":null,"error_msg":null,"error":1}
i also test with status_code and that give number 200 that mean ok right ?
so what the problem with my code? thanks before
code:
Chia sẻ bài đăng này
Link tới bài viết
Share on other sites