• [^] # Re: Oh oh que c'est nul

    Posté par (site web personnel) . En réponse au journal Oh oh que c'est nul. Évalué à 2.

    Tu n'as pas mon méga script python :-)
    import httplib
    def get_code(cnx, format, num):
     url = format%num
     cnx.request("GET", url)
     rsp = cnx.getresponse().status
     print url, rsp
     return rsp
    def main():
     format = "http://linuxfr.org/comments/%d.html(...)"
     cnx = httplib.HTTPConnection("linuxfr.org")
     low = 100000
     try:
     num = int(open("find_big.txt", "rt").read())
     low = num
     except:
     pass
     progress = 20
     high = low
     while 1:
     high += progress
     rsp = get_code(cnx, format, high)
     if rsp!=200:
     break
     low = high
     progress *= 2
     while low<high:
     cur = (low+high)/2
     url = format%cur
     rsp = get_code(cnx, format, cur)
     #print cur, "->", rsp.status
     if rsp==200:
     low = cur+1
     else:
     high = cur
     print "->", format%high
     open("find_big.txt", "wt").write(str(low-1))
    if __name__=="__main__":
     main()