我使用discord.py对机器人进行编码,我试图根据用户关键字从谷歌搜索中获取链接
@client.event
async def on_message(message):
## GOOGLE SEARCH
#####################################################################################
if message.content.startswith('!google'):
msg = message.content
query = msg.split(" ")[1]
headers = { }
headers['User-Agent'] = 'Mozilla/5.0'
url = 'http://www.google.com/search?q='
value = { 'q' : query }
data = urllib.parse.urlencode(value)
data = data.encode('utf-8')
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
final = response.read()
我认为这是一个错误
urllib.error.HTTPError:HTTP错误405:不允许的方法