Herramientas de usuario

Herramientas del sitio


informatica:lenguajes_de_programacion:python:python_urrlib

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anteriorRevisión previa
Próxima revisión
Revisión previa
informatica:lenguajes_de_programacion:python:python_urrlib [2026/01/31 06:30] admininformatica:lenguajes_de_programacion:python:python_urrlib [2026/02/01 05:58] (actual) admin
Línea 3: Línea 3:
   * [[https://stackabuse.com/guide-to-sending-http-requests-in-python-with-urllib3/]]   * [[https://stackabuse.com/guide-to-sending-http-requests-in-python-with-urllib3/]]
  
 +| **Informational codes**                        | (between 100 and 199)                               |
 +| **Successful codes**                           | (between 200 and 299) - 200 is the most common one  |
 +| **Redirect codes**                             | (between 300 and 399)                               |
 +| **Client error codes**                         | (between 400 and 499) - 404 is the most common one  |
 +| **Server error codes**                         | (between 500 and 599) - 500 is the most common one  |
  
  
Línea 18: Línea 23:
 with open('T.json', 'wb') as file: with open('T.json', 'wb') as file:
    file.write(r)    file.write(r)
 +
 +</code>
 +
 +<code python>
 +
 +import urllib.request
 +import shutil
 +
 +
 +
 +#proxy_address = 'http://45.186.6.104:3128'
 +#proxy_address = 'http://96.126.117.23:80'
 +#proxies = {'http': proxy_address, 'https': proxy_address}
 +#proxy_handler = urllib.request.ProxyHandler(proxies)
 +#opener = urllib.request.build_opener(proxy_handler)
 +#urllib.request.install_opener(opener)
 +
 +
 +headers = {'User-Agent': 'PostmanRuntime/7.51.0',
 +            'Charsets':'utf-8',
 +            'Accept':'*/*'}#'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0'}
 +request = urllib.request.Request("<URL>", headers=headers)
 +r = urllib.request.urlopen(request).read()
 +#print(r.decode('utf-8'))
 +#with open("R.json", 'w') as out:
 +#   shutil.copyfileobj(r, out)
 +with open('T.json', 'wb') as file:
 +   file.write(r)
 +
  
 </code> </code>
informatica/lenguajes_de_programacion/python/python_urrlib.1769841032.txt.gz · Última modificación: 2026/01/31 06:30 por admin