2016-03-04 31 views
1

说我有一个网址,如http://www.ebay.com/itm/Harry%20Potter%20and%20the%20Deathly%20Hallows%207%20by%20J.%20K.%20Rowling%20(2007,%201st%20Edition)/322028146082鉴于eBay的URL,有没有办法让项目详细

我想获得这个项目的细节,但API接缝要求我知道的信息像他们的productId,我没有。我会怎么做呢?


虽然来问这个问题,我找到了我的答案,但如果有人有任何其他意见,我会很感激。


编辑

所以,当我来到了用这个,我意识到我还没有完全回答我自己的问题。尽管我有关于商品价格等的详细信息,但我无法获取productID,甚至没有UPC,ASIN,EAN,ISBN或任何东西,除非商品有多个变体,在这种情况下,它可能用于区分上述变体。我仍然不确定这是否可行,如果是这样,为什么它在eBay的API帮助中没有更突出的特征。

+0

item id是url结尾的12位数字,你可以用正则表达式来提取它。然后,使用getsingleitem来提取您需要的数据。 –

+0

是的,这是我在我的回答中详细解释的 – theheadofabroom

+0

哈,对不起我没有刷新页面有罪:) –

回答

1

所以据我所知,这应该是ePN文档中的第一件事,因此在这里发布了一个问题和答案。我花了很多时间看产品API和Finding API,然后才发现这是你需要能够作为购物者找到的东西。

您可以使用eBay购物API的GetSingleItem方法获取此信息。这只需要知道在URL中找到的ItemID。在这个例子中,它是斜线后面的数字,但是有几种不同的URL格式,所以最好是用10+数字的正则表达式匹配。如果你需要比这更多的信息,有交易的API,这是一个有点复杂

<?xml version="1.0" encoding="UTF-8"?> 
<GetSingleItemResponse xmlns="urn:ebay:apis:eBLBaseComponents"> 
    <Timestamp>2016-03-04T14:43:46.784Z</Timestamp> 
    <Ack>Success</Ack> 
    <Build>E949_CORE_APILW_17769283_R1</Build> 
    <Version>949</Version> 
    <Item> 
     <ItemID>322028146082</ItemID> 
     <EndTime>2016-04-03T13:41:26.000Z</EndTime> 
     <ViewItemURLForNaturalSearch>http://www.ebay.com/itm/Harry-Potter-and-Deathly-Hallows-7-J-K-Rowling-2007-1st-Edition-/322028146082</ViewItemURLForNaturalSearch> 
     <ListingType>FixedPriceItem</ListingType> 
     <Location>Kings Mountain, North Carolina</Location> 
     <GalleryURL>http://thumbs3.ebaystatic.com/pict/3220281460828080_1.jpg</GalleryURL> 
     <PictureURL>http://i.ebayimg.com/00/s/MTYwMFgxMTY4/z/I~kAAOSwJb9WsVh9/$_1.JPG?set_id=8800005007</PictureURL> 
     <PictureURL>http://i.ebayimg.com/00/s/MTYwMFg5NDM=/z/l8sAAOSwpzdWsVie/$_1.JPG?set_id=8800005007</PictureURL> 
     <PrimaryCategoryID>171228</PrimaryCategoryID> 
     <PrimaryCategoryName>Books:Fiction &amp; Literature</PrimaryCategoryName> 
     <BidCount>0</BidCount> 
     <ConvertedCurrentPrice currencyID="USD">12.5</ConvertedCurrentPrice> 
     <ListingStatus>Active</ListingStatus> 
     <TimeLeft>P29DT22H57M40S</TimeLeft> 
     <Title>Harry Potter and the Deathly Hallows 7 by J. K. Rowling (2007, 1st Edition)</Title> 
     <Country>US</Country> 
     <AutoPay>true</AutoPay> 
    </Item> 
</GetSingleItemResponse> 

一旦你有这样的要求很简单,比如http://open.api.ebay.com/shopping?callname=GetSingleItem&itemId=322028146082&appid=[YOUR_APP_ID]&version=515会给你。对于这一点,你必须对https://api.ebay.com/ws/api.dll

页眉XML或SOAP POST请求是这样的:

X-EBAY-API-COMPATIBILITY-LEVEL: 949 
X-EBAY-API-APP-NAME: [YOUR_APP_ID] 
X-EBAY-API-DEV-NAME: [YOUR_DEV_ID] 
X-EBAY-API-CERT-NAME: [YOUR_CERT_ID] 
X-EBAY-API-CALL-NAME: GetItem 
X-EBAY-API-SITEID: 0 

身体是这样的:

<?xml version="1.0" encoding="utf-8"?> 
<GetItemRequest xmlns="urn:ebay:apis:eBLBaseComponents"> 
    <RequesterCredentials> 
     <eBayAuthToken>[YOUR_AUTH_TOKEN]</eBayAuthToken> 
    </RequesterCredentials> 
    <ItemID>322028146082</ItemID> 
</GetItemRequest> 

提交这应该给你的身体像:

<?xml version="1.0" encoding="UTF-8"?> 
<GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents"> 
    <Timestamp>2016-03-04T16:40:00.981Z</Timestamp> 
    <Ack>Success</Ack> 
    <Version>949</Version> 
    <Build>E949_CORE_API_17775483_R1</Build> 
    <Item> 
     <AutoPay>true</AutoPay> 
     <BuyerProtection>ItemIneligible</BuyerProtection> 
     <BuyItNowPrice currencyID="USD">0.0</BuyItNowPrice> 
     <Country>US</Country> 
     <Currency>USD</Currency> 
     <GiftIcon>0</GiftIcon> 
     <HitCounter>NoHitCounter</HitCounter> 
     <ItemID>322028146082</ItemID> 
     <ListingDetails> 
      <Adult>false</Adult> 
      <BindingAuction>false</BindingAuction> 
      <CheckoutEnabled>true</CheckoutEnabled> 
      <ConvertedBuyItNowPrice currencyID="USD">0.0</ConvertedBuyItNowPrice> 
      <ConvertedStartPrice currencyID="USD">12.5</ConvertedStartPrice> 
      <HasReservePrice>false</HasReservePrice> 
      <StartTime>2016-03-04T13:41:26.000Z</StartTime> 
      <EndTime>2016-04-03T13:41:26.000Z</EndTime> 
      <ViewItemURL>http://www.ebay.com/itm/Harry-Potter-and-Deathly-Hallows-7-J-K-Rowling-2007-1st-Edition-/322028146082</ViewItemURL> 
      <HasUnansweredQuestions>false</HasUnansweredQuestions> 
      <HasPublicMessages>false</HasPublicMessages> 
      <ViewItemURLForNaturalSearch>http://www.ebay.com/itm/Harry-Potter-and-Deathly-Hallows-7-J-K-Rowling-2007-1st-Edition-/322028146082</ViewItemURLForNaturalSearch> 
     </ListingDetails> 
     <ListingDuration>Days_30</ListingDuration> 
     <ListingType>FixedPriceItem</ListingType> 
     <Location>Kings Mountain, North Carolina</Location> 
     <PaymentMethods>PayPal</PaymentMethods> 
     <PrimaryCategory> 
      <CategoryID>171228</CategoryID> 
      <CategoryName>Books:Fiction &amp; Literature</CategoryName> 
     </PrimaryCategory> 
     <PrivateListing>false</PrivateListing> 
     <Quantity>1</Quantity> 
     <ReviseStatus> 
      <ItemRevised>true</ItemRevised> 
     </ReviseStatus> 
     <Seller> 
      <AboutMePage>false</AboutMePage> 
      <Email>Invalid Request</Email> 
      <FeedbackScore>82</FeedbackScore> 
      <PositiveFeedbackPercent>0.0</PositiveFeedbackPercent> 
      <FeedbackPrivate>false</FeedbackPrivate> 
      <FeedbackRatingStar>Blue</FeedbackRatingStar> 
      <IDVerified>false</IDVerified> 
      <eBayGoodStanding>true</eBayGoodStanding> 
      <NewUser>false</NewUser> 
      <RegistrationDate>2007-05-30T12:11:34.000Z</RegistrationDate> 
      <Site>US</Site> 
      <Status>Confirmed</Status> 
      <UserID>westbrandbooks</UserID> 
      <UserIDChanged>false</UserIDChanged> 
      <UserIDLastChanged>2016-02-02T14:57:13.000Z</UserIDLastChanged> 
      <VATStatus>NoVATTax</VATStatus> 
      <SellerInfo> 
       <AllowPaymentEdit>true</AllowPaymentEdit> 
       <CheckoutEnabled>true</CheckoutEnabled> 
       <CIPBankAccountStored>false</CIPBankAccountStored> 
       <GoodStanding>true</GoodStanding> 
       <LiveAuctionAuthorized>false</LiveAuctionAuthorized> 
       <MerchandizingPref>OptIn</MerchandizingPref> 
       <QualifiesForB2BVAT>false</QualifiesForB2BVAT> 
       <StoreOwner>false</StoreOwner> 
       <SafePaymentExempt>false</SafePaymentExempt> 
      </SellerInfo> 
      <MotorsDealer>false</MotorsDealer> 
     </Seller> 
     <SellingStatus> 
      <BidCount>0</BidCount> 
      <BidIncrement currencyID="USD">0.0</BidIncrement> 
      <ConvertedCurrentPrice currencyID="USD">12.5</ConvertedCurrentPrice> 
      <CurrentPrice currencyID="USD">12.5</CurrentPrice> 
      <MinimumToBid currencyID="USD">12.5</MinimumToBid> 
      <QuantitySold>0</QuantitySold> 
      <ReserveMet>true</ReserveMet> 
      <SecondChanceEligible>false</SecondChanceEligible> 
      <ListingStatus>Active</ListingStatus> 
      <QuantitySoldByPickupInStore>0</QuantitySoldByPickupInStore> 
     </SellingStatus> 
     <ShippingDetails> 
      <ApplyShippingDiscount>false</ApplyShippingDiscount> 
      <CalculatedShippingRate> 
       <WeightMajor measurementSystem="English" unit="lbs">0</WeightMajor> 
       <WeightMinor measurementSystem="English" unit="oz">0</WeightMinor> 
      </CalculatedShippingRate> 
      <SalesTax> 
       <SalesTaxPercent>0.0</SalesTaxPercent> 
       <ShippingIncludedInTax>false</ShippingIncludedInTax> 
      </SalesTax> 
      <ShippingServiceOptions> 
       <ShippingService>ShippingMethodStandard</ShippingService> 
       <ShippingServiceCost currencyID="USD">0.0</ShippingServiceCost> 
       <ShippingServicePriority>1</ShippingServicePriority> 
       <ExpeditedService>false</ExpeditedService> 
       <ShippingTimeMin>1</ShippingTimeMin> 
       <ShippingTimeMax>6</ShippingTimeMax> 
       <FreeShipping>true</FreeShipping> 
      </ShippingServiceOptions> 
      <ShippingType>Flat</ShippingType> 
      <ThirdPartyCheckout>false</ThirdPartyCheckout> 
      <ShippingDiscountProfileID>0</ShippingDiscountProfileID> 
      <InternationalShippingDiscountProfileID>0</InternationalShippingDiscountProfileID> 
      <SellerExcludeShipToLocationsPreference>true</SellerExcludeShipToLocationsPreference> 
     </ShippingDetails> 
     <ShipToLocations>US</ShipToLocations> 
     <Site>US</Site> 
     <StartPrice currencyID="USD">12.5</StartPrice> 
     <TimeLeft>P29DT21H1M26S</TimeLeft> 
     <Title>Harry Potter and the Deathly Hallows 7 by J. K. Rowling (2007, 1st Edition)</Title> 
     <HitCount>6</HitCount> 
     <LocationDefaulted>true</LocationDefaulted> 
     <GetItFast>false</GetItFast> 
     <BuyerResponsibleForShipping>false</BuyerResponsibleForShipping> 
     <PostalCode>28086</PostalCode> 
     <PictureDetails> 
      <GalleryType>Gallery</GalleryType> 
      <GalleryURL>http://i.ebayimg.com/00/s/MTYwMFgxMTY4/z/I~kAAOSwJb9WsVh9/$_1.JPG?set_id=8800005007</GalleryURL> 
      <PhotoDisplay>None</PhotoDisplay> 
      <PictureURL>http://i.ebayimg.com/00/s/MTYwMFgxMTY4/z/I~kAAOSwJb9WsVh9/$_1.JPG?set_id=8800005007</PictureURL> 
      <PictureURL>http://i.ebayimg.com/00/s/MTYwMFg5NDM=/z/l8sAAOSwpzdWsVie/$_1.JPG?set_id=8800005007</PictureURL> 
     </PictureDetails> 
     <DispatchTimeMax>3</DispatchTimeMax> 
     <ProxyItem>false</ProxyItem> 
     <BuyerGuaranteePrice currencyID="USD">20000.0</BuyerGuaranteePrice> 
     <IntangibleItem>false</IntangibleItem> 
     <ReturnPolicy> 
      <ReturnsAcceptedOption>ReturnsNotAccepted</ReturnsAcceptedOption> 
      <ReturnsAccepted>No returns accepted</ReturnsAccepted> 
     </ReturnPolicy> 
     <ConditionID>4000</ConditionID> 
     <ConditionDescription>Book is used but in good shape. May contain scribbles and/or notes in the margins.</ConditionDescription> 
     <ConditionDisplayName>Very Good</ConditionDisplayName> 
     <PostCheckoutExperienceEnabled>false</PostCheckoutExperienceEnabled> 
     <ShippingPackageDetails> 
      <ShippingIrregular>false</ShippingIrregular> 
      <ShippingPackage>PackageThickEnvelope</ShippingPackage> 
      <WeightMajor measurementSystem="English" unit="lbs">0</WeightMajor> 
      <WeightMinor measurementSystem="English" unit="oz">0</WeightMinor> 
     </ShippingPackageDetails> 
     <RelistParentID>321997285555</RelistParentID> 
     <HideFromSearch>false</HideFromSearch> 
     <eBayPlus>false</eBayPlus> 
     <eBayPlusEligible>false</eBayPlusEligible> 
    </Item> 
</GetItemResponse> 
相关问题