0

I am using python and I want to get token value and store it in a variable. Can someone please tell me how to get token value as I am a beginner in python.

Below is the string from which I want to extract the value:

`jQuery18209123624774221071_1620226978533({"status":"success","message":"Login successfully","data":`{"user_id":"UJiH0","user_fname":"MyName","user_mname":"","user_lname":"MyLastName","user_gender":"M","user_email":"[email protected]","user_email_mig":"","user_lastdt":"2021-05-06 10:50:59","entdate":"2020-12-03 08:16:59","user_mobile":"919999999999","user_defview":"4","user_nick":"ashmit","email_verify":"1","mobile_verify":"1","user_add1":"","user_add2":"","user_state":"MyState","user_country":"MyCountry","user_pincode":"MyPincode","user_hint":"","user_fax":"","user_dob":"MyDOB","user_city":"MyCity","user_occupation":"Student","income_status":"MyIncome","industry":"Information Technology","marital_status":"","user_defsort":"","user_defcolor":"","user_stkworth":"","user_mfworth":"","user_ulipworth":"","user_loansworth":"","user_debtworth":"","user_metalsworth":"","user_asstworth":"","user_borrworth":"","user_propworth":"","user_list":"","portfolio_mailer":"","news_mailer":"","mf_mailer":"","user_refrate":"","user_seenflag":"","user_rel_optin":"","user_portviewperm":"","user_oldid":"","port_unsub_flag":"","user_mobile_updated":"91-9999999999","user_isd_code":"91","usertype":"email","user_country_code":"MyCountryCode","user_state_code":"MyStateCode","user_city_code":"MyCityCode","member_type":"New","userimg":"http:\/\/img-d02.moneycontrol.co.in\/images\/messageboard\/home\/img.jpg","dispname":"ashmit"},"token":"PemRcaHEDX0bPl9OF1tUD5Xv9J7V8DrR0k3tNjoLLc5hs3xSg9vI5cMj75qbsF6g3-03NJnNEw"})
18
  • Remove everything up to the first (, remove the last ), then use json.loads() to parse the rest. Commented May 6, 2021 at 16:11
  • Where are you getting that from? That's a JSONP response, usually the API will also have a JSON option. Commented May 6, 2021 at 16:12
  • I am getting it while scrapping some data Commented May 6, 2021 at 16:27
  • @Barmar can you also help in this Question stackoverflow.com/questions/67405043/… Commented May 6, 2021 at 16:28
  • I removed the thing before '(' and also removed last ')' using logreq = logreq.replace('jQuery18209123624774221071_1620226978533(','') logreq = logreq.replace(')','') . Now what ? @Barmar Commented May 6, 2021 at 16:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.