Guest User

Sourcecode: flauschangriff_strawpoll_0.01a

a guest
May 5th, 2018
834
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2. import json
  3. import time
  4. import requests
  5. from tqdm import tqdm
  6. from random import shuffle
  7.  
  8. tqdm.monitor_interval = 0
  9.  
  10. print("Für wenn soll gevotet werden? Bitte wählen:");
  11. print("");
  12. print("1) Zufällige Partei bei jedem Voting (außer AfD natürlich)");
  13. print("2) Für CDU/CSU) abstimmen");
  14. print("3) Für SPD) abstimmen");
  15. print("4) Für FDP) abstimmen");
  16. print("5) Für Die Linke ) abstimmen");
  17. print("6) Für Bündnis 90/Die Grünen) abstimmen");
  18. print("7) Für Keine der genannten Parteien) abstimmen");
  19.  
  20. answer = input()
  21.  
  22. print("");
  23.  
  24. defaultKeys = {
  25.     'protocol': "protocol",
  26.     'postSupport': "post",
  27.     'httpsSupport': "supportsHttps",
  28.     'ip': "ip",
  29.     'port': "port",
  30.     'country': "country",
  31.     'status_code': "status_code",
  32.     'error': "error",
  33. }
  34.  
  35. proxyAPIs = [
  36.     {
  37.         'url': "https://gimmeproxy.com/api/getProxy",
  38.         'overLimitStatusCode': 429,
  39.         'keys': {**defaultKeys, **{
  40.             'protocol': "type",
  41.         }}
  42.     },
  43.     {
  44.         'url': "https://api.getproxylist.com/proxy",
  45.         'overLimitStatusCode': 429,
  46.         'keys': {**defaultKeys, **{
  47.             'postSupport': "allowsPost",
  48.             'httpsSupport': "allowsHttps",
  49.         }}
  50.     },
  51. ]
  52.  
  53. apiIdx = 0
  54. api = proxyAPIs[apiIdx]
  55.  
  56. while True:
  57.  
  58.     try:
  59.  
  60.         # Get proxy
  61.         gotProxy = False
  62.         consecutiveLimitOverflow = 0
  63.         while not gotProxy:
  64.            
  65.             response = requests.get(api['url'])
  66.            
  67.             proxy = json.loads(response.content)
  68.  
  69.             if api['keys']['status_code'] in proxy and proxy[api['keys']['status_code']] == api['overLimitStatusCode'] or api['keys']['error'] in proxy:
  70.                 consecutiveLimitOverflow += 1
  71.                 if consecutiveLimitOverflow == len(proxyAPIs):
  72.                     print("Anfragelimit aller Proxy APIs erreicht - Warte 60 Sekunden. In dieser Zeit kannst du deinen Router neu verbinden, um das Limit aufzuheben.")
  73.                     for _ in tqdm(range(120)):
  74.                         time.sleep(0.5)
  75.                 # Get next api
  76.                 print("Die Proxy API wird nun gewechselt, da das Anfragelimit erreicht wurde...")
  77.                 apiIdx += 1
  78.                 if apiIdx == len(proxyAPIs):
  79.                     apiIdx = 0
  80.                 api = proxyAPIs[apiIdx]
  81.                 print("Neue API: {}".format(api['url']))
  82.             elif api['keys']['httpsSupport'] in proxy and proxy[api['keys']['httpsSupport']] and proxy[api['keys']['protocol']] in ["http","https"]:
  83.                 consecutiveLimitOverflow = 0
  84.                 gotProxy = True
  85.        
  86.         proxyUrl = "{}://{}:{}".format(proxy[api['keys']['protocol']], proxy[api['keys']['ip']], proxy[api['keys']['port']])
  87.         proxies = { "http": proxyUrl, "https": proxyUrl }
  88.  
  89.         # Available options        
  90.         options = {
  91.             'check5410728': "CDU/CSU",
  92.             'check5410729': "SPD",
  93.             'check5410730': "FDP",
  94.             'check5410731': "Die Linke ",
  95.             'check5410732': "Bündnis 90/Die Grünen",
  96.             'check5410734': "Keine der genannten Parteien",
  97.         }
  98.  
  99.         # Choose option
  100.         if answer == "2":
  101.             option = "check5410728"
  102.         elif answer == "3":
  103.             option = "check5410729"
  104.         elif answer == "4":
  105.             option = "check5410730"
  106.         elif answer == "5":
  107.             option = "check5410731"
  108.         elif answer == "6":
  109.             option = "check5410732"
  110.         elif answer == "7":
  111.             option = "check5410734"
  112.         else:
  113.             optionIds = list(options.keys())
  114.             shuffle(optionIds)
  115.             option = optionIds[0]
  116.  
  117.         # Vote
  118.  
  119.         data = {
  120.             "pid": "37x4318", # Poll ID
  121.             "oids": option
  122.         }
  123.  
  124.         headers = {
  125.             'Accept': "*/*",
  126.             'Accept-Encoding': "gzip, deflate, br",
  127.             'Accept-Language': "en,en-US;q=0.9,en-DE;q=0.8,de-DE;q=0.7,de;q=0.6",
  128.             'Connection': "keep-alive",
  129.             'Content-Length': "29",
  130.             'Content-Type': "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
  131.             'Host': "strawpoll.de",
  132.             'Origin': "https://strawpoll.de",
  133.             'Referer': "https://strawpoll.de/37x4318",
  134.             'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36",
  135.             'X-Requested-With': "XMLHttpRequest",
  136.             'Cache-Control': "no-cache",
  137.         }
  138.  
  139.         print("Nutze Proxy IP {} (Land: {})".format(proxy[api['keys']['ip']], proxy[api['keys']['country']]))
  140.  
  141.         try:
  142.             # Vote
  143.             print("Vote für '{}'".format(options[option]))
  144.             response = requests.post("https://strawpoll.de/vote?pid=37x4318&oids=check5410731", data=json.dumps(data), proxies=proxies, headers=headers)
  145.             parsed = json.loads(response.content);
  146.             print(re.sub('<[^<]+?>', '', parsed['message']))
  147.         except requests.exceptions.RequestException:
  148.             # Error
  149.             print("Voten fehlgeschlagen")
  150.  
  151.         print("----------")
  152.  
  153.         # Wait
  154.         time.sleep(3)
  155.  
  156.     except KeyboardInterrupt:
  157.  
  158.         print("Abbruch durch Nutzer")
  159.         exit()
  160.  
  161.     except Exception as e:
  162.  
  163.         pass
RAW Paste Data