Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 31st, 2013  |  syntax: None  |  size: 1.84 KB  |  views: 2,009  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Traceback (most recent call last):
  2.   File "script.py", line 7, in <module>
  3.     proxy = urllib2.ProxyHandler(line)
  4.   File "/usr/lib/python2.7/urllib2.py", line 713, in __init__
  5.     assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
  6. AssertionError: proxies must be a mapping
  7.        
  8. import urllib2  
  9. u=open('urls.txt')
  10. p=open('proxies.txt')
  11. for line in p:
  12.     proxy = urllib2.ProxyHandler(line)
  13.     opener = urllib2.build_opener(proxy)
  14.     urllib2.install_opener(opener)
  15.     for url in u:
  16.         urllib.urlopen(url).read()
  17.  
  18. u.close()
  19. p.close()
  20.        
  21. 'www.google.com'
  22. 'www.facebook.com'
  23. 'www.reddit.com'
  24.        
  25. {'https': 'https://94.142.27.4:3128'}
  26. {'http': 'http://118.97.95.174:8080'}
  27. {'http':'http://66.62.236.15:8080'}
  28.        
  29. p=open('proxies.txt')
  30. for line in p:
  31.     proxy = urllib2.ProxyHandler(line)
  32.        
  33. p=open('proxies.txt')
  34. for line in p:
  35.     d = ast.literal_eval(line)
  36.     proxy = urllib2.ProxyHandler(d)
  37.        
  38. {"https": "https://94.142.27.4:3128"}
  39. {"http": "http://118.97.95.174:8080"}
  40. {"http": "http://66.62.236.15:8080"}
  41.        
  42. import json
  43. import urllib2  
  44.  
  45. with open('proxies.txt') as proxies:
  46.     for line in proxies:
  47.         proxy = json.loads(line)
  48.         proxy_handler = urllib2.ProxyHandler(proxy)
  49.         opener = urllib2.build_opener(proxy_handler)
  50.         urllib2.install_opener(opener)
  51. with open('urls.txt') as urls:
  52.     for line in urls:
  53.         url = line.rstrip()
  54.         data = urllib.urlopen(url).read()
  55.         # do something with data
  56.        
  57. with open('urls.txt') as f:
  58.     urls = [line.rstrip() for line in f]
  59. with open('proxies.txt') as proxies:
  60.     for line in proxies:
  61.         proxy = json.loads(line)
  62.         proxy_handler = urllib2.ProxyHandler(proxy)
  63.         opener = urllib2.build_opener(proxy_handler)
  64.         urllib2.install_opener(opener)
  65.         for url in urls:
  66.             data = urllib.urlopen(url).read()
  67.             # do something with data