得到了我的小機械化代碼:Python的機械化忽略表單輸入的HTML
br.open('http://tumblr.com/customize');
print br.response().read()
print br.form['edit_tumblelog[cname]'] # there definitely is edit_tumblelog
# and br.form['edit_tumblelog[enable_cname]'] works fine
輸出:
...
<br/>
<input type="text" class="text_field" style="width:275px; min-width:0px;
margin:6px 0px; border:solid 1px #d2d2d2;
"
name="cname" id="cname"
onchange="form_changed = true;"
value="blog.yay.com"
/>
...
Traceback (most recent call last):
File "/tmp/temp_textmate.W6p5gh", line 51, in <module>
print br.form['edit_tumblelog[cname]']
File "/Library/Python/2.6/site-packages/ClientForm-0.2.10-py2.6.egg/ClientForm.py", line 2891, in __getitem__
File "/Library/Python/2.6/site-packages/ClientForm-0.2.10-py2.6.egg/ClientForm.py", line 3222, in find_control
File "/Library/Python/2.6/site-packages/ClientForm-0.2.10-py2.6.egg/ClientForm.py", line 3306, in _find_control
ClientForm.ControlNotFoundError: no control matching name 'edit_tumblelog[cname]'
我在做什麼錯?
我不熟悉這個方括號表示法來識別控件 - 你能給出一個URL來記錄它,以便我可以研究它嗎?我,我已經使用了'br.select_form(name ='edit_tumblelog')'(假設這是表單的名字),然後使用'br ['cname']',但是如果我可以找到文檔,方括號表示看起來很有趣爲它,並使其正確工作 - 謝謝! – 2010-03-06 23:48:40