【发布时间】:2017-03-24 08:56:29
【问题描述】:
我想编写一些可以在网页中输入文本的代码;即在网页http://www.dictionary.com/ 中查找一个单词。我找到的代码如下(我使用的是 Python 3.5):
import urllib.request
import urllib.parse
value= {'q', 'something'}
value= urllib.parse.urlencode(value)
value= value.encode('utf-8')
f= urllib.request.Request('http://www.dictionary.com/', value)
g= urllib.request.urlopen(f)
print(g.geturl())
但是,print(g.geturl()) 打印 http://www.dictionary.com/,与我一开始的链接相同。我希望它在搜索栏中搜索“某物”。
【问题讨论】:
标签: python python-3.5