我正在尝试在文本区域输入数据,
<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>
但是我很困惑该怎么做,因为没有与此相关的形式。这是网站的link。我非常感谢您在输入文字方面的帮助。
最佳答案
尽管很明显,这里可能会应用不同的解决方案-对于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
...
关于python - 使用机械化Python在textarea中输入数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27927385/