我正在尝试使用R在站点的API上使用eBay进行搜索。然而,我完全不知所措,不知该如何做。
我熟悉在R中使用其他API,例如Twitter和Instagram。其中一些搜索可以使用专用库(twitteR、streamR等)进行,但我也不得不用httr和RCurl拼凑起来。不幸的是,我在ebay上对这样的方法一点运气都没有。我试过了:
getURL(''http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords
&SERVICE-VERSION=1.0.0
&SECURITY-APPNAME=My_App_ID
&GLOBAL-ID=EBAY-US
&RESPONSE-DATA-FORMAT=JSON
&callback=_cb_findItemsByKeywords
&REST-PAYLOAD
&keywords=harry%20potter
&paginationInput.entriesPerPage=3')它没有起作用。我也试过了:
url <- "http://svcs.ebay.com/services/search/FindingService/v1"
xml.request <- "<?OPERATION-NAME=findItemsByKeywords
&SERVICE-VERSION=1.0.0
&SECURITY-APPNAME=My_App_ID
&GLOBAL-ID=EBAY-US
&RESPONSE-DATA-FORMAT=XML
&callback=_cb_findItemsByKeywords
&REST-PAYLOAD
&keywords=harry%20potter
&paginationInput.entriesPerPage=3>"
myheader=c(Connection="close",
'Content-Type' = "application/xml",
'Content-length' =nchar(xml.request))
data = getURL(url = url,
postfields=xml.request,
httpheader=myheader,
verbose=TRUE)这个也不走运。基本上,我不知道我在做什么。有人能帮上忙吗?
发布于 2017-12-20 12:37:36
我已经用一个新的名为ebayr的R包包装了ebay的with API,它带有一个httr::GET调用。查看此处:https://github.com/gsimchoni/ebayr
您需要从https://go.developer.ebay.com/获取令牌,然后就可以使用了。
这里也有一篇博客文章来寻找灵感:http://giorasimchoni.com/2017/12/19/2017-12-19-e-is-for-elephant-the-ebayr-package/
发布于 2016-12-06 02:52:39
url <- 'http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=USER_ADD_ID&GLOBAL-ID=EBAY-US&keywords=macbook+refurbished&paginationInput.entriesPerPage=10'
getURL(url)
> getURL(url)
[1] "<?xml version='1.0' encoding='UTF-8'?><findItemsByKeywordsResponse xmlns=\"http://www.ebay.com/marketplace/search/v1/services\"><ack>Success</ack><version>1.13.0</version><timestamp>2016-12-05T18:48:43.170Z</timestamp><searchResult count=\"10\"><item><itemId>152233530373</itemId><title>Apple Macbook Air 11.6\" 1.3 GHz Core i5 128 GB SSD, 4GB RAM, Yosemite- MD711LL/A</title><globalId>EBAY-US</globalId><subtitle>OS Upgraded to 10.10 Yosemite l Cosmetic Condition 8/10</subtitle><primaryCategory><categoryId>111422</categoryId><categoryName>Apple Laptops</categoryName></primaryCategory><galleryURL>http://thumbs2.ebaystatic.com/m/mpUZSSnEfwJ5YOFJ8JzcmXw/140.jpg</galleryURL><viewItemURL>http://www.ebay.com/itm/Apple-Macbook-Air-11-6-1-3-GHz-Core-i5-128-GB-SSD-4GB-RAM-Yosemite-MD711LL-A-/152233530373</viewItemURL><productId type=\"ReferenceID\">160128184</productId><paymentMethod>PayPal</paymentMethod><autoPay>true</autoPay><location>USA</location><country>US</country><shippingInfo><shipp... <truncated>参考Getting Started with the Finding API: Finding Items by Keywords
https://stackoverflow.com/questions/34615760
复制相似问题