-
Notifications
You must be signed in to change notification settings - Fork 1
/
wordpress.py
25 lines (22 loc) · 843 Bytes
/
wordpress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Author: Carey Dayrit
from locust import HttpUser, task, between
from bs4 import BeautifulSoup
import time
import requests
class MyLocust(HttpUser):
wait_time = between(1, 10)
@task
def homepage(self):
self.client.get("/", headers={"Cookie": "no-cache"})
@task(1)
def sitemap(self):
host=self.host
url=host + "/wp-sitemap.xml"
soup=BeautifulSoup(requests.get(url).text, 'lxml')
for loc in soup.select('sitemap > loc'):
subxml=loc.text[len(host):]
suburl = host + subxml
subsoup = BeautifulSoup(requests.get(suburl).text, 'lxml')
for subloc in subsoup.select('url > loc'):
subdirectory=subloc.text[len(host):]
self.client.get(subdirectory, headers={"Cookie": "no-cache"})