MCPcopy
hub / github.com/tychxn/jd-assistant / get_user_info

Method get_user_info

jd_assistant.py:390–410  ·  view source on GitHub ↗

获取用户信息 :return: 用户名

(self)

Source from the content-addressed store, hash-verified

388
389 @check_login
390 def get_user_info(self):
391 """获取用户信息
392 :return: 用户名
393 """
394 url = 'https://passport.jd.com/user/petName/getUserInfoForMiniJd.action'
395 payload = {
396 'callback': 'jQuery{}'.format(random.randint(1000000, 9999999)),
397 '_': str(int(time.time() * 1000)),
398 }
399 headers = {
400 'User-Agent': self.user_agent,
401 'Referer': 'https://order.jd.com/center/list.action',
402 }
403 try:
404 resp = self.sess.get(url=url, params=payload, headers=headers)
405 resp_json = parse_json(resp.text)
406 # many user info are included in response, now return nick name in it
407 # jQuery2381773({"imgUrl":"//storage.360buyimg.com/i.imageUpload/xxx.jpg","lastLoginTime":"","nickName":"xxx","plusStatus":"0","realName":"xxx","userLevel":x,"userScoreVO":{"accountScore":xx,"activityScore":xx,"consumptionScore":xxxxx,"default":false,"financeScore":xxx,"pin":"xxx","riskScore":x,"totalScore":xxxxx}})
408 return resp_json.get('nickName') or 'jd'
409 except Exception:
410 return 'jd'
411
412 def _get_item_detail_page(self, sku_id):
413 """访问商品详情页

Callers 2

login_by_usernameMethod · 0.95
login_by_QRcodeMethod · 0.95

Calls 2

parse_jsonFunction · 0.90
getMethod · 0.80

Tested by

no test coverage detected