论如何获取洛谷所有用户的ID

发布于 2019-05-21  1153 次阅读


前段时间改名的时候问了一些kkk可不可以在某些地方看到洛谷全部人的ID

然后kkk说没有这种东西,那这就让我很纳闷了,如果连某个ID是否被使用都不知道那岂不是很尴尬

所有我就突发奇想写了一个长得很丑,跑得很慢的python来抓出全部人的用户ID

然并卵,真的很慢
也不知是网络还是匹配的问题,反正很慢就是了


#-*- coding: UTF-8 -*-
import urllib2
import urllib
import re
import linecache

def getHtml(url):
    headers={'User-Agent':'Mozilla/5.0 (compatible; MSIE 5.5; Windows NT)'}
    request=urllib2.Request(url,headers=headers)
    html=urllib2.urlopen(request)
    return html.read()
for i in range(1, 30000):
    url="https://www.luogu.org/space/show?uid="+str(i)
    html=getHtml(url)
    html=html.splitlines(400)[164]
    reg=re.compile(r'.+?<')
    piclist=re.findall(reg,html)
    for pic in piclist:
        x=len(pic)
        xx=x-22
        pic=pic[-xx:]
        x=len(pic)
        x=x-1
        pic=pic[:x]
        print pic
]]>