Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Instalar python cualquier version
- #Asegurarse que este agregado en la variable de entorno PATH de Windows
- #entrar a una ventana de DOS y ejecutar: pip install schedule requests
- #copiar el siguiente script en un archivo y ejecutar con : python ruta/a/archivo
- import schedule
- import sys
- import time
- import random
- from time import strftime, localtime
- import requests
- SEG=10
- #En comentarios los servidores que responden lento.
- URL_SPEEDTEST= [
- "http://speedtest31.amx.com.pe/speedtest/random350x350.jpg",
- "http://speedtest11.amx.com.pe/speedtest/random350x350.jpg",
- "http://medidor1.optical.com.pe/speedtest/random350x350.jpg",
- "http://medidor.fiberluxperu.com/speedtest/random350x350.jpg",
- "http://ookla-was.telefonica.net.pe/speedtest/random350x350.jpg",
- "http://speedtest.bitel.com.pe/speedtest/random350x350.jpg",
- "http://speedtest21.amx.com.pe/speedtest/random350x350.jpg",
- "http://ookla-are.telefonica.net.pe/speedtest/random350x350.jpg",
- "http://speedtest41.amx.com.pe/speedtest/random350x350.jpg"
- ]
- def getRandomURL():
- return URL_SPEEDTEST[random.randint(0,len(URL_SPEEDTEST)-1)]
- def downloadFile(URL=None):
- if (URL == ""):
- URL_END=getRandomURL()
- else:
- URL_END=URL
- print("["+strftime("%a, %d %b %Y %H:%M:%S +0000", localtime()) + "]::Llamando url - " + URL_END)
- r = requests.get(URL_END, timeout=3)
- return
- schedule.every(SEG).seconds.do(downloadFile,"")
- print("[Cada " + str(SEG) + " Segundos / Ctrl + C Cancela]")
- downloadFile(getRandomURL())
- try:
- while True:
- schedule.run_pending()
- time.sleep(1)
- except KeyboardInterrupt:
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement