我正在尝试一个收集智能设备数据的项目。我已经决定使用eBay python SDK,而不是依靠网络抓取。我有一些问题
当我请求某个特定物品时,例如“iPhone x 64gb”,我会得到一个响应,即易趣物品列表。在这些列表中,一些列表项可能以a.)的形式出现,一个iphone6的列表,这不是我想要的。b、 )两部手机的列表(例如iPhone x 64 Gb和256gb版本)。我该如何过滤这些混乱
python SDK的文档还不够,因为我需要更多关于过滤XML响应以及向API请求添加搜索过滤器的指导
我必须对同一个项目进行多次调用,但响应将发送另一个页码(最多100页,每页100个项目)。我通常会看到很多相同物品的清单,相同的价格,它们的URL指向同一个卖家。这可能无助于我对诸如“iPhoneX”日均售价等指标进行准确的统计分析。我如何从API中获得更好的示例数据,因为我不会得到所有的“iPhoneX”列表
使用查找API时会遇到所有问题
from ebaysdk.finding import Connection as find_connect
from statistics import mean, median
from bs4 import BeautifulSoup
APP_ID = 'Removed for privacy reasons'
# keywords = input("Enter search keywords(e.g 'white board'): ")
api = find_connect(appid=APP_ID, config_file=None, siteid="EBAY-ENCA")
request = {
'keywords': "Iphone x 64gb",
'itemFilter': [
{'name': 'Condition', 'value': 'Used'},
{'name': 'currency', 'value': 'CAD'},
{'name': 'minPrice', 'value': 100.0}
],
'paginationInput': {
'entriesPerPage': 100,
'pageNumber': 1
},
}
response = api.execute('findItemsByKeywords', request)
# print(responses.dict())
soup = BeautifulSoup(response.content, 'lxml')
totalentries = int(soup.find('totalentries').text)
items = soup.find_all('item')
print(f"{totalentries} items found")
print_no = 0
prices = []
print(f"Current list is {len(items)} items long")
for item in items:
cat = item.categoryname.string.lower()
title = item.title.string.lower()
price = int(round(float(item.currentprice.string)))
url = item.viewitemurl.string.lower()
print('-'*20)
print(f"{cat}\n{title}\n{price}\n{url}\n")
prices.append(price)
print_no += 1
print(f"{print_no} items have been printed")
print(f"Average price is ${mean(prices)}. Median is ${median(prices)}")
我可以接收输出,例如
3242 items found
Current list is 100 items long
--------------------
# The problem about two different phones in one listing that I was talking about
cell phones & smartphones
apple iphone x silver & gray gsm unlocked 64gb or 256gb
600
https://www.ebay.ca/itm/apple-iphone-x-silver-gray-gsm-unlocked-64gb-256gb-/273580927268?var=572990606496
--------------------
# Basically a duplicate of the above listing
cell phones & smartphones
apple iphone x silver & gray gsm unlocked 64gb or 256gb
600
https://www.ebay.ca/itm/apple-iphone-x-silver-gray-gsm-unlocked-64gb-256gb-/273580927268?var=572990606496
--------------------
# I did not search for an iPhone 8
mobile phones
apple iphone 8 - 64gb - silver (unlocked) model a1863
152
https://www.ebay.ca/itm/apple-iphone-8-64gb-silver-unlocked-model-a1863-/174235235608
--------------------
# This is what I wanted
cell phones & smartphones
apple iphone x 64gb silver unlocked 5.8 in ios smartphone-visible shadow/burn-in
460
https://www.ebay.ca/itm/apple-iphone-x-64gb-silver-unlocked-5-8-ios-smartphone-visible-shadow-burn-in-/174212340572?var=473126790373
--------------------
# X not Xs max
mobile phones
apple iphone xs max [64gb / 256gb /512gb] cheap unlocked [au stock] free express
1019
https://www.ebay.ca/itm/apple-iphone-xs-max-64gb-256gb-512gb-cheap-unlocked-au-stock-free-express-/324024310348?var=513068412663
100 items have been printed # removed most listings from output for brevity
Average price is $566.2. Median is $600
事实上,几个月前我已经完成了非常类似的项目(对于移动公司,pricings的统计分析也是如此)。 下面是我的简短且易于实现的存储库:https://github.com/Brat-Pit/eBay
我的一般方法是:使用findItemAdvanced()获取项目的ID列表,然后使用GetMultipleItems()获取其他数据
但是,回到你的问题:
Ad.1如果您想以某种方式过滤项目,首先获取项目的ID列表(例如使用findItemAdvanced()中的价格/描述过滤器)。然后使用ebaysdk.shopping和方法GetMultipleItems()。您可以访问项目的属性(如RAM内存、屏幕大小等)
广告2是这样的。我大约80%的信息是从论坛获得的,20%是通过文档获得的
广告3我理解你的观点。每日查询限制为5000次。我的解决方案是首先使用findItemAdvanced()(根据单个指定的排序顺序对返回的项目进行排序)。 默认设置:BestMatch。所以你不需要做排序之类的事情),然后只下载最受欢迎的拍卖(用户挑选/购买它们并非没有原因,这是幕后的主要想法)
希望能有帮助
您可以按方面而不是关键字进行查询。这将带来更多的预期结果
相关问题 更多 >
编程相关推荐