Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 易趣物品价格表从低价到高价_Python 3.x_Sorting_Beautifulsoup_Ebay Api - Fatal编程技术网

Python 3.x 易趣物品价格表从低价到高价

Python 3.x 易趣物品价格表从低价到高价,python-3.x,sorting,beautifulsoup,ebay-api,Python 3.x,Sorting,Beautifulsoup,Ebay Api,目前,我正在进行一个项目,在这个项目中,我必须从低到高查看易趣中物品的价格。我该怎么做 我得到的价格很好,但不是按顺序排列的 以下是我的代码片段: from ebaysdk.finding import Connection as finder from bs4 import BeautifulSoup keywords=input("enter keywords") api=finder(appid='Mahxxxxxxxxxxxxxxxxxxx',config_file=None) api_

目前,我正在进行一个项目,在这个项目中,我必须从低到高查看易趣中物品的价格。我该怎么做

我得到的价格很好,但不是按顺序排列的

以下是我的代码片段:

from ebaysdk.finding import Connection as finder
from bs4 import BeautifulSoup
keywords=input("enter keywords")
api=finder(appid='Mahxxxxxxxxxxxxxxxxxxx',config_file=None)
api_req={'keywords':keywords,'outputSelector':'SellerInfo'}
response=api.execute('findItemsByKeywords',api_req)
soup=BeautifulSoup(response.content,'lxml')
total=int(soup.find('totalentries').text)
items=soup.find_all('item')
for i in items:
cat=i.categoryname.string.lower()
title=i.title.string.lower()
price=int(round(float(i.currentprice.string)))
seller=i.sellerusername.text.lower()
list=i.listingtype.string.lower()
url=i.viewitemurl.string.lower()

print("----------------------------------------")

print(title)
print(price)
print(seller)
print(url)
下面是我得到的输出:

apple iphone x 64gb 256gb at&t sprint unlocked us cellular verizon
856
alltechwholesale
----------------------------------------
apple iphone x 64gb 256gb space gray silver (unlocked) at&t - t-mobile - sprint
919
iphones.tested.trusted
----------------------------------------
apple iphone x - 256gb - silver (at&t) a1901 (gsm)
875
abooghait

事后你不需要自己整理,但如果你愿意,当然可以

您正在使用eBay API,特别是查找API,更具体地说,是调用“findItemsByKeywords”。因此,您可以访问过多的过滤器和排序选项。是您可以使用的排序顺序,包括一些定价排序


我不熟悉您正在使用的语言或SDK,但不知何故,您需要插入用于指定排序的代码。

如果您添加了一段刮页面的代码,也许我们可以更好地帮助您。还有,为什么不在你这边排序呢?好的,我会上传,我有个问题。我应该把价格列在清单上,并在最后进行分类吗?@ManasJayanth更新了hanks的回复。我使用的是'findItemsByKeywords',我想使用'CurrentPriceHighest'作为排序顺序。但我不知道如何使用它。你能解释一下吗?附言:我正在使用Python3、ebaySDK和beautifulsou