Best Python code snippet using localstack_python
scraper.py
Source:scraper.py  
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    ]...proxy.py
Source:proxy.py  
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()...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
