Best Python code snippet using localstack_python
regex_parsing.py
Source:regex_parsing.py
...6в алÑавиÑном поÑÑдке7"""8import re9import requests10def get_domain_names(url: str) -> list:11 """request url, get domain names from string like <a ... href="..." ... >"""12 domains_list = []13 page = requests.get(url=url)14 if page:15 for page_line in page.text.splitlines():16 page_line = page_line.rstrip()17 domain_pattern = r'(<a.+href=[\'\"])([^\.\.\\]\w*\:\/\/)([\w\.\-]*)'18 domain_search = re.search(pattern=domain_pattern, string=page_line)19 if domain_search:20 domain_name = domain_search.group(3)21 if domain_name not in domains_list:22 domains_list.append(domain_name)23 domains_list.sort()24 return domains_list25# for manual input26URL = input().rstrip()27#############28## testing29#############30# URL = 'http://pastebin.com/raw/2mie4QYa' # test 131# URL = 'http://pastebin.com/raw/hfMThaGb' # test 232# URL = 'http://pastebin.com/raw/7543p0ns' # test 333domains_found = get_domain_names(URL)34for domain_name in domains_found:35 print(domain_name)36#####37# get correct output for test 338correct_list = []39with open('test_3_output.txt', encoding='utf-8', newline='') as f_check:40 for line in f_check.read().splitlines():41 correct_list.append(line)42# check for missing links43for line in correct_list:44 if line not in domains_found:...
main.py
Source:main.py
...7date = str(input("Enter the date for PDNS query: "))8date = datetime.strptime(date, '%Y%m%d').strftime("%Y%m%d")9# outputFile = 'outputFile.txt'1011domainExtractor.get_domain_names(inputFile, limit, date)12# domainExtractor.get_domain_names(inputFile, limit, outputFile, date)13# jsonCreator.txt_to_json(limit, outputFile)14
...
ips2domain_name.py
Source:ips2domain_name.py
...4 """5 List all hosts with domain name from current subnet.6 """7 ips = get_subnet_ips(exclude_own=True, verbose=True)8 for ip, domain_name in get_domain_names(ips=ips):9 print(f'{ip:<13} -> {domain_name}')10if __name__ == '__main__':...
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!!