フォーラムのQQ号を登ります


#       ,      ,  

import random
import re
import urllib.request

listQqAll = []
listNum = []
for i in range(1,50):
    #   49      xx      49 
    urlPath = "xx     "  #                 Xx,        ,    , -_-
    #        ,    
    agentsList = [
        "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Maxthon/4.4.3.4000 Chrome/30.0.1599.101 Safari/537.36",
        "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
        "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.84 Safari/535.11 SE 2.X MetaSr 1.0"
    ]

    #            
    userAgent = random.choice(agentsList)
    #        ,           
    resquetXx = urllib.request.Request(urlPath, headers={"User-Agent": userAgent})
    #     ,    
    responseXx = urllib.request.urlopen(urlPath)
    #      
    strXx = responseXx.read().decode("utf-8")
    #   QQ   (       QQ )
    listXx = re.findall("QQ\D{,3}[1-9]\d{4,10}",strXx,re.I)
    listQqAll.extend(listXx)  #      QQ         
    listNumber = set(listQqAll)   #   set        
    #       QQ    
    for qqAndNum in listNumber:
        qqNum = re.findall("\d{5,10}",qqAndNum)  #   QQ       
        listNum.extend(qqNum)  # QQ         
setNum = set(listNum)  #           
# print(setNum)
for num in setNum:  #        
    #      qq.txt  ,   QQ       
    with open(r"qq.txt","a",encoding="utf-8") as af:
        af.write("QQ:" + num + "
"
) # af.flush()