[英]Enter data in textarea using mechanize Python
我正在嘗試將數據輸入文本區域,該區域顯示
<textarea class="help_text" cols="40" id="annotation_text" name="annotation[text]" rows="15" style="box-shadow: 0 0 3px gray; padding: 5px; width: 600px;" title="Enter or paste text to be annotated"></textarea>
但是我很困惑該怎么做,因為沒有與此相關的形式。 這是網站的鏈接 。 我非常感謝您在輸入文字方面的幫助。
盡管很明顯,這里可能會應用不同的解決方案-這對於mechanize
來說並非易事。 更好地使用requests
進行提交(POST請求):
import requests
url = 'http://bioportal.bioontology.org/annotator'
params = {
'text': 'Sample text', # this is the contents of the text area
'longest_only': 'false',
'raw': 'true'
}
# start a web-scraping session (mostly, for maintaining cookies)
session = requests.Session()
session.get(url)
# submit the "form"
response = session.post(url, data=params)
data = response.json()
# get the annotations
for annotation in data['annotations']:
print annotation['annotatedClass']['prefLabel']
打印:
Sample
sample
sample
sample
Specimen
Sample
...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.