How to use get_proxies method in localstack

Best Python code snippet using localstack_python

scraper.py

Source:scraper.py Github

copy

Full Screen

1from fake_useragent import UserAgent2from requests import get3from re import findall4ua = UserAgent()5def get_proxies(url):6 text = ""7 response = get(url, headers={'User-Agent': ua.random})8 content = response.text.replace("<span> : </span> <em>", ":")9 content = content.replace("</td><td>", ":")10 for proxy, port in findall('((?:\d{1,3}\.){3}\d{1,3}):(\d+)', content):11 text += proxy + ":" + port + "\n"12 print("+", len(text.splitlines()))13 return text14proxies = [15 get_proxies('https://api.proxyscrape.com/?request=getproxies&proxytype=socks5&timeout=10000&country=all'),16 get_proxies('https://proxysource.org/api/proxies/getWorkingProxies?apiToken=17580e4438910c287cef15dca10b7912a26&latencyMax=15000&latencyMin=0&outputMode=plaintext&uptimeMax=100&uptimeMin=30'),17 "\n".join(18 get_proxies(19 "https://raw.githubusercontent.com/TheSpeedX/SOCKS-List/master/socks5.txt"20 ).splitlines()[2:]),21 get_proxies('https://raw.githubusercontent.com/ShiftyTR/Proxy-List/master/socks5.txt'),22 "\n".join(23 get_proxies(24 "https://www.freeproxychecker.com/result/socks5_proxies.txt"25 ).splitlines()[7:]),26 get_proxies('https://multiproxy.org/txt_all/proxy.txt'),27 get_proxies('http://rootjazz.com/proxies/proxies.txt'),28 get_proxies('http://ab57.ru/downloads/proxyold.txt'),29 get_proxies('https://www.proxy-list.download/api/v1/get?type=socks5'),30 get_proxies('https://www.proxyscan.io/download?type=socks5'),31 get_proxies('http://proxydb.net/?protocol=socks5'),32 get_proxies('https://kabak.top/socks5'),33 get_proxies('https://hidemy.name/en/proxy-list/?type=5#list'),34 get_proxies('https://www.socks-proxy.net/'),35 get_proxies('https://www.my-proxy.com/free-socks-5-proxy.html')36 ]...

Full Screen

Full Screen

proxy.py

Source:proxy.py Github

copy

Full Screen

2# -*-coding:UTF-8-*-3# __author__ : pighui4# __time__ : 2019-11-2 上午11:515import requests6def get_proxies(params: dict = {}):7 '''8 :param params: 参数字典 默认为空9 :return: 返回一个包含多条代理信息的列表,列表的每一个元素是一个字典10 '''11 try:12 response = requests.get('http://127.0.0.1:8888/ip/', params=params)13 if response.status_code == 200:14 result = response.json()15 return [{d['protocol']: 'http://' + d['ip'] + ':' + d['port']} for d in result]16 except ConnectionError:17 return None18def random_proxy():19 '''20 :return: 返回一个代理信息字典21 '''22 try:23 response = requests.get('http://127.0.0.1:8888/ip/random/')24 if response.status_code == 200:25 result = response.json()26 return result27 except ConnectionError:28 return None29if __name__ == '__main__':30 # 获取一条代理31 ip1 = get_proxies()32 print(ip1)33 # 获取多条代理34 ip2 = get_proxies({'count': 3})35 print(ip2)36 # 获取匿名代理37 ip3 = get_proxies({'anonymity': 1})38 print(ip3)39 # 获取https代理40 ip4 = get_proxies({'protocol': 'https'})41 print(ip4)42 # 获取多条匿名的https代理43 ip5 = get_proxies({'count': 3, 'anonymity': 1, 'protocol': 'https'})44 print(ip5)45 # 随机获取一条代理46 ip6 = random_proxy()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful