# API Reference: Testing for XSS Vulnerabilities
## requests Library for XSS Testing
### Reflection Testing
```python
from urllib.parse import quote
# Inject canary to find reflection points
resp = requests.get(f"{url}?q={canary}")
if canary in resp.text:
# Input is reflected - test payloads
resp = requests.get(f"{url}?q={quote(payload)}")
```
## XSS Payload Categories
| Context | Example Payload |
|---------|----------------|
| HTML body | `` |
| HTML attribute | `" onfocus=alert(1) autofocus="` |
| JavaScript string | `';alert(1)//` |
| URL/href | `javascript:alert(1)` |
| Event handler | `
` |
| SVG | `