Retourner au contenu associé (journal : Oh oh que c'est nul)
Posté par Fabimaru (site web personnel) le 08 octobre 2003 à 11:37. En réponse au journal Oh oh que c'est nul. Évalué à 2.
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()
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
[^] # Re: Oh oh que c'est nul
Posté par Fabimaru (site web personnel) . En réponse au journal Oh oh que c'est nul. Évalué à 2.
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()