Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Feature]: Submit the issue of duplicate key-value pairs in the form #2834

Open
@KaHuier

Description

@KaHuier

🚀 Feature Request

Submit the issue of duplicate key-value pairs in the form

Example

The data required by the server interface is as follows:
test=1&test=2&test=3&mc=kaka

The implementation plan for sending requests is outlined below:

importrequestsresponse=requests.post(url='http://127.0.0.1:5000/form',verify=False,data={"test": ["1","2","3"],"mc":"kaka"    })print(response.text)

It should be noted that Playwright does not natively support passing repeated key-value pairs, as they are escaped during serialization. To address this limitation, the following temporary solution has been implemented:

fromtypingimportOptional,List,Dictfromplaywright._impl._helperimportNameValuedefobject_to_array(obj:Optional[Dict])->Optional[List[NameValue]]:ifnotobj:returnNoneresult= []forkey,valueinobj.items():ifisinstance(value, (tuple,list)):forvinvalue:result.append(NameValue(name=key,value=str(v)))else:result.append(NameValue(name=key,value=str(value)))returnresult_helper.object_to_array=object_to_arrayfromplaywright.sync_apiimportsync_playwrightplaywright=sync_playwright().start()browser=playwright.chromium.launch()page=browser.new_page()response=page.request.post(url='http://127.0.0.1:5000/form',form={"test": ["1","2","3"],"mc":"kaka"    })print(response.text)

Motivation

When encountering a duplicate key-value pair that needs to be submitted in the form in the interface

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp