Python 如何将odoo与IMDb集成?
我正在尝试集成一个有自己API的odoo 我需要把电影作为产品放在奥多上,然后在奥多上下采购订单 该网站说,为了搜索,我应该使用此api“我必须但我的密钥在这里”&t=“我要搜索的电影名称” 我试着用这种方法做这件事Python 如何将odoo与IMDb集成?,python,api,web-services,integration,odoo,Python,Api,Web Services,Integration,Odoo,我正在尝试集成一个有自己API的odoo 我需要把电影作为产品放在奥多上,然后在奥多上下采购订单 该网站说,为了搜索,我应该使用此api“我必须但我的密钥在这里”&t=“我要搜索的电影名称” 我试着用这种方法做这件事 class Api(http.Controller): @http.route('/api', auth='public', methods=["get"]) def index(self, **kw): url = 'http://www.omdbapi.com/?api
class Api(http.Controller):
@http.route('/api', auth='public', methods=["get"])
def index(self, **kw):
url = 'http://www.omdbapi.com/?apikey=15439843&t=hello'
r = requests.get(url)
return r.text
它返回一个json,其中包含电影hello的数据
但这里是一个静态参数,如何使其动态化并从字段或数据输入中获取电影名称,然后我需要在product.tempalte的create方法中获取json参数
add_product = http.request.env['product.template'].sudo().create({
'name': "movie name form json"
})
return add_product
非常感谢您的帮助我使用Postman生成了这段代码,这将让您了解如何从链接处理查询字符串param
import requests
url = "http://www.omdbapi.com/"
querystring = {"apikey":"15439843","t":"hello"} # your parameters here in query string
headers = { 'Cache-Control': "no-cache", 'Connection': "keep-alive", 'cache-control': "no-cache" }
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)