我正在使用 robobrowser 库,我遇到了一个表单:
<form action="/results" id="search">
<div class="s_ctr">
<fieldset>
<label class="jaw" for="ln">Search by Name</label><input type="text" placeholder="Search by Name" autocomplete="off" value="" tabindex="1" name="ln" maxlength="255" class="name" id="ln" data-key="true"><span>near</span><label class="jaw" for="loc">Enter City, State</label><input type="text" placeholder="Enter City, State" autocomplete="off" value="" tabindex="2" name="loc" maxlength="255" class="location" id="loc" data-key="true">
</fieldset>
<input type="submit" value="Find Physician" class="orange-btn" tabindex="4" id="btn-submit">
</div>
</form>
我的代码:
search_form = browser.get_form(id='search')
search_form
search_form.fields['1']= name
search_form.fields['2']= address
# # Submit the form
browser.submit_form(search_form)
browser
我收到以下错误和回溯:
Traceback:
File "C:\r1\lib\site-packages\django\core\handlers\base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\r1\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
57. return view_func(*args, **kwargs)
File "C:\r1\mlist\ml1\views.py" in ph
48. p = getPhone(A.name,A.address)
File "C:\r1\mlist\ml1\views.py" in getPhone
191. browser.submit_form(search_form)
File "C:\r1\lib\site-packages\robobrowser\browser.py" in submit_form
343. payload = form.serialize(submit=submit)
File "C:\r1\lib\site-packages\robobrowser\forms\form.py" in serialize
225. return Payload.from_fields(include_fields)
File "C:\r1\lib\site-packages\robobrowser\forms\form.py" in from_fields
118. payload.add(field.serialize(), field.payload_key)
Exception Type: AttributeError at /ph/
Exception Value: 'unicode' object has no attribute 'serialize'
可以使用 robobrowser 提交此表单吗?