· 7 years ago · Dec 19, 2018, 09:12 PM
1import requests
2import os
3import random
4import string
5import json
6
7
8import requests
9from lxml.html import fromstring
10from itertools import cycle
11import traceback
12import random
13
14
15
16user_agent_list = [
17 # Chrome
18 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
19 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
20 'Mozilla/5.0 (Windows NT 5.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
21 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
22 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36',
23 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36',
24 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',
25 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',
26 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
27 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36',
28 # Firefox
29 'Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)',
30 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko',
31 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
32 'Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko',
33 'Mozilla/5.0 (Windows NT 6.2; WOW64; Trident/7.0; rv:11.0) like Gecko',
34 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko',
35 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0)',
36 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko',
37 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)',
38 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; Trident/7.0; rv:11.0) like Gecko',
39 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
40 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)',
41 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)'
42]
43
44def get_proxies():
45 url = 'https://free-proxy-list.net/'
46 response = requests.get(url)
47 parser = fromstring(response.text)
48 proxies = set()
49 for i in parser.xpath('//tbody/tr')[:10]:
50 if i.xpath('.//td[7][contains(text(),"yes")]'):
51 #if i.xpath('.//td[5][contains(text(),"elite proxy")]'):
52 proxy = ":".join([i.xpath('.//td[1]/text()')[0], i.xpath('.//td[2]/text()')[0]])
53 proxies.add(proxy)
54 return proxies
55
56proxies = get_proxies()
57proxy_pool = cycle(proxies)
58
59#url = 'https://httpbin.org/ip'
60for i in range(1,11):
61 #Get a proxy from the pool
62 proxy = next(proxy_pool)
63 print("Request #%d"%i)
64
65 # Pick a random user agent
66 user_agent = random.choice(user_agent_list)
67 # Set the headers
68 headers = {'User-Agent': user_agent}
69 # Make the request
70 #response = requests.get(url, headers=headers)
71
72 try:
73 url = 'https://httpbin.org/ip'
74 response = requests.get(url,proxies={"http": proxy, "https": proxy}, headers=headers)
75 print(response.json())
76
77 url = 'https://httpbin.org/user-agent'
78 response = requests.get(url,proxies={"http": proxy, "https": proxy}, headers=headers)
79 print(response.json())
80 except:
81 #Most free proxies will often get connection errors. You will have retry the entire request using another proxy to work.
82 #We will just skip retries as its beyond the scope of this tutorial and we are only downloading a single url
83 print("Skipping. Connnection error")
84
85
86
87chars = string.ascii_letters + string.digits + '!@#$%^&*()'
88random.seed = (os.urandom(1024))
89
90url = 'www.scammersite.com/something'
91
92names = json.loads(open('nameslist.JSON').read())
93
94for name in names:
95 name_extra = ' '.join(random.choice(string.digits))
96
97 username = name.lower() + name_extra + '@gmail.com'
98 password = ' ' .join(random.choice(chars) for i in range(10))
99
100 requests.post(url, allow_redirects=False, data={
101 'stringsdoigjnina': username,
102 'stringiousdhnafj': password
103 })
104
105 print('sending username %s and password %s' %(username, password))