Skip to content

Commit

Permalink
fix 无法连接sp0.baidu.com时无法发送媒体播放消息
Browse files Browse the repository at this point in the history
  • Loading branch information
Shurelol committed May 9, 2023
1 parent c956e8a commit 9e239d5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions web/backend/web_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ def get_location(ip):
url = 'https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?co=&resource_id=6006&t=1529895387942&ie=utf8' \
'&oe=gbk&cb=op_aladdin_callback&format=json&tn=baidu&' \
'cb=jQuery110203920624944751099_1529894588086&_=1529894588088&query=%s' % ip
r = RequestUtils().get_res(url)
r.encoding = 'gbk'
html = r.text
try:
c1 = html.split('location":"')[1]
c2 = c1.split('","')[0]
return c2
r = RequestUtils().get_res(url)
if r:
r.encoding = 'gbk'
html = r.text
c1 = html.split('location":"')[1]
c2 = c1.split('","')[0]
return c2
else:
return ""
except Exception as err:
ExceptionUtils.exception_traceback(err)
return ""
Expand Down

0 comments on commit 9e239d5

Please sign in to comment.