首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Ebay API时出错

使用Ebay API时出错
EN

Stack Overflow用户
提问于 2014-09-29 13:42:31
回答 1查看 834关注 0票数 0

我试图使用ebaysdk模块访问Ebay API。我正在使用文档中给出的示例代码,并已在Ebay Developer的站点上注册以生成所需的App。

ebaay.py

代码语言:javascript
复制
from ebaysdk.finding import Connection as Finding

api = Finding(appid="123456789")
response = api.execute('findItemsAdvanced', {'keywords': 'Python'})
print(response.dict())

YAML文件(假设我的应用程序id为123456789)

代码语言:javascript
复制
# eBay SDK Defaults
name: ebay_api_config
# Trading API Sandbox - https://www.x.com/developers/ebay/products/trading-api
api.sandbox.ebay.com:
compatability: 719
appid: 123456789
certid: ENTER_YOUR_CERTID_HERE
devid: ENTER_YOUR_DEVID_HERE
token: ENTER_YOUR_TOKEN_HERE

# Trading API - https://www.x.com/developers/ebay/products/trading-api
api.ebay.com:
version: 719
appid: 123456789
certid: ENTER_YOUR_CERTID_HERE
devid: ENTER_YOUR_DEVID_HERE
token: ENTER_YOUR_TOKEN_HERE

# Finding API - https://www.x.com/developers/ebay/products/finding-api
svcs.ebay.com:
appid: 123456789
version: 1.0.0

# Shopping API - https://www.x.com/developers/ebay/products/shopping-api
open.api.ebay.com:
appid: 123456789
version: 671
# Optional affiliate tracking
# http://developer.ebay.com/DevZone/shopping/docs/Concepts/ShoppingAPI_FormatOverview.html#StandardURLParameters
trackingid: ENTER_YOUR_TRACKINGID_HERE
trackingpartnercode: ENTER_YOUR_PARTNERCODE_HERE 

但是,当我试图运行Python脚本时,会遇到以下错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "E:/Python27/Web Scraping/ebaay.py", line 3, in <module>
    api = Finding(appid="123456789")
  File "C:\Python27\lib\site-packages\ebaysdk\finding\__init__.py", line 70, in __init__
    config_file=kwargs.get('config_file', 'ebay.yaml'))
  File "C:\Python27\lib\site-packages\ebaysdk\config.py", line 39, in __init__
    self._populate_yaml_defaults()
  File "C:\Python27\lib\site-packages\ebaysdk\config.py", line 50, in _populate_yaml_defaults
    for k, val in dataobj.get(self.domain, {}).items():
AttributeError: 'NoneType' object has no attribute 'items'

我的密码怎么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-09 22:24:13

您需要缩进每个API字段:

代码语言:javascript
复制
# eBay SDK Defaults
name: ebay_api_config
# Trading API Sandbox - https://www.x.com/developers/ebay/products/trading-api
api.sandbox.ebay.com:
    compatability: 719
    appid: 123456789
    certid: ENTER_YOUR_CERTID_HERE
    devid: ENTER_YOUR_DEVID_HERE
    token: ENTER_YOUR_TOKEN_HERE

# Trading API - https://www.x.com/developers/ebay/products/trading-api
api.ebay.com:
    version: 719
    appid: 123456789
    certid: ENTER_YOUR_CERTID_HERE
    devid: ENTER_YOUR_DEVID_HERE
    token: ENTER_YOUR_TOKEN_HERE

# Finding API - /developers/ebay/products/finding-api
svcs.ebay.com:
    appid: 123456789
    version: 1.0.0

# Shopping API - /developers/ebay/products/shopping-api
open.api.ebay.com:
    appid: 123456789
    version: 671

此外,如果在Finding()文件中包含了appid,则不必将appid放在ebaay.py中的ebay.yaml调用中。api = Finding()会工作的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26101372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档