osm.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:kort-core 作者: kort 项目源码 文件源码
def get_user_info(data) -> object:
    oauth_token = data.get('oauth_token')
    oauth_token_secret = data.get('oauth_token_secret')

    userinfo = {}
    userinfo['oauth_token'] = oauth_token
    userinfo['oauth_token_secret'] = oauth_token_secret

    url = "http://api.openstreetmap.org/api/0.6/user/details"
    auth = OAuth1(BaseConfig.OSM_CONSUMER_KEY, BaseConfig.OSM_CONSUMER_SECRET, oauth_token, oauth_token_secret)
    resp = requests.get(url, auth=auth)

    tree = ElementTree.fromstring(resp.content)
    for child in tree:
        if child.tag == 'user':
            userinfo['display_name'] = child.attrib.get('display_name')
            userinfo['id'] = child.attrib.get('id')
            for innerChild in child:
                if innerChild.tag == 'img':
                    userinfo['img'] = innerChild.attrib.get('href')
    return userinfo
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号