import gevent.monkey gevent.monkey.patch_all() import random import requests import time from xml.etree import ElementTree from locust import HttpUser, task, between wms_list = [] def get_requests (url, user, password): response = requests.get(url = url, auth = (user, password)) catalog = ElementTree.fromstring(response.content) entries = catalog.findall('{http://www.w3.org/2005/Atom}entry') for entry in entries : wms_offers = entry.findall('{http://www.opengis.net/owc/1.0}offering[@code="http://www.opengis.net/spec/owc-atom/1.0/req/wms"]') for offer in wms_offers : services = offer.findall('{http://www.opengis.net/owc/1.0}operation[@code="GetMap"]') if len(services) > 0 : wms_list.append(services[0].get('href').replace('https://emg.pdas.prism.eox.at/','')) # replace the strings 'username' and 'Password' with the pdas/vs credintials get_requests('https://emg.pdas.prism.eox.at/opensearch/collections/Emergency/atom/', 'username', 'password' ) class QuickstartUser(HttpUser): wait_time = between(0, 0) @task(3) def view_item(self): item_id = random.randint(0, len(wms_list)-1) item = wms_list[item_id] # replace the strings 'username' and 'Password' with the pdas/vs credintials self.client.get(f"{item}", auth=('username', 'password'))