[英]Error while working with Ebay API
我正在尝试使用ebaysdk模块访问Ebay API。 我正在使用文档中提供的示例代码,并已在Ebay Developer的网站上注册以生成所需的App ID。 这是我程序的源代码:
ebaay.py
from ebaysdk.finding import Connection as Finding
api = Finding(appid="123456789")
response = api.execute('findItemsAdvanced', {'keywords': 'Python'})
print(response.dict())
YAML文件(假设我的应用程序ID为123456789)
# 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脚本时,遇到以下错误:
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'
我的代码似乎有什么问题?
您需要缩进每个API字段:
# 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
另外,如果您在ebay.yaml文件中有appid,则不必将appid放在ebaay.py的Finding()
调用中。 api = Finding()
将起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.