我尝试使用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)
也没有运气。基本上,我不知道我在做什么。有人可以帮忙吗?
答案 0 :(得分:1)
我已经使用名为ebayr
的新R套餐包裹ebay的Finding 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/
答案 1 :(得分:0)
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