当前位置:网站首页>Crawler for querying nicknames and avatars based on qqwebapi

Crawler for querying nicknames and avatars based on qqwebapi

2022-04-23 18:00:00 Round programmer

API See for details QQWEB file .
Environmental Science python3.8+win

import requests
import re
from PIL import Image
from io import BytesIO

def getQQPhoto(qqCode):
    url ="https://q4.qlogo.cn/g?b=qq&nk={}&s=100".format(qqCode)
    headers = {
    
        'Referer': 'http://pic.netbian.com/4kmeinv/index_2.html',
        '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'
    }

    response = requests.get(url = url, headers = headers).content
    #  take bytes The result is converted to a byte stream 
    bytes_stream = BytesIO (response)
    #  Read picture 
    roiimg = Image.open(bytes_stream)
    roiimg.show()  # Show pictures 



def getQQName(qqCode):
    url = 'http://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?g_tk=1518561325&uins=' + qqCode
    headers = {
    
        'Referer': 'http://pic.netbian.com/4kmeinv/index_2.html',
        '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'
    }

    response = requests.get(url = url, headers = headers).text
    response= response.encode('iso-8859-1').decode('gbk')
    r = re.findall(',"(.*?)",0]}\)', response)[0]
    print("NickName: ", r)

if __name__ == '__main__':
    nums = list(map(str, input(" Please enter QQ Number ( Separate spaces between multiple signs ):").split()))
    for num in nums:
        getQQName(num)
        getQQPhoto(num)


版权声明
本文为[Round programmer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230545315678.html