#!/usr/bin/env python
# coding=UTF-8
from time import time as timer
import urllib2
import random
import argparse
parser = argparse.ArgumentParser(description='Luminati 多线程刷点击脚本')
parser.add_argument('--thread', '-t', help='线程数',default=10)
parser.add_argument('--country', '-c', help='国家,自动从 Luminati 选择对应国家代理', required=True)
parser.add_argument('--url', '-u', help='目标地址', required=True)
parser.add_argument('--number', '-n', help='请求数量', required=True)
args = parser.parse_args()
def random_line(afile):
line = next(afile)
for num, aline in enumerate(afile, 2):
if random.randrange(num): continue
line = aline
return line
def fetch_url(url):
username = 'lum-customer-用户-zone-通道名称-country-' + args.country
password = '修改为你的密码'
port = 22225
session_id = random.random()
super_proxy_url = ('http://%s-session-%s:%s@zproxy.lum-superproxy.io:%d' %
(username, session_id, password, port))
proxy_handler = urllib2.ProxyHandler({
'http': super_proxy_url,
'https': super_proxy_url,
})
opener = urllib2.build_opener(proxy_handler)
try:
response = opener.open(url,timeout=10)
return url, response.read(), None
except Exception as e:
return url, None, e
urls = [];
for i in range(int(args.number)):
urls.append(args.url)
start = timer()
for url in urls
fetch_url(url);
print("总消耗时间: %s" % (timer() - start,))
更新了一个小 BUG
这个脚本是帮客户开发的,为了保护客户利益,去掉了多线程,去掉了 User-Agent 选择等。
有需要的找我来做定制。