Advertisement
Guest User

8Kun image viewer 0.1

a guest
Aug 28th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. import requests
  2. import urllib3
  3. from PIL import Image
  4. from io import BytesIO
  5. from unittest.mock import patch
  6. import argparse
  7.  
  8. def connect_to(host, port):
  9.     from urllib3.util.connection import create_connection as orig_create_connection
  10.  
  11.     def _forced_address_connection(address, *args, **kwargs):
  12.         forced_address = (host, port)
  13.         return orig_create_connection(forced_address, *args, **kwargs)
  14.  
  15.     return patch('urllib3.util.connection.create_connection', _forced_address_connection)
  16.  
  17. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  18. ns = ['94.103.81.80', '94.103.82.74', '94.103.94.73', '195.2.93.193', '193.178.169.19']
  19. parser = argparse.ArgumentParser()
  20. parser.add_argument('url')
  21. args = parser.parse_args()
  22.  
  23. for media in ns:
  24.     try:
  25.         url = args.url
  26.         with connect_to(media, 443):
  27.             r = requests.get(url, verify=False)
  28.         print(r.history)
  29.         img = Image.open(BytesIO(r.content))
  30.         img.show()
  31.     except Exception as error:
  32.         print(error)
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement