Advertisement
Guest User

ebay

a guest
Dec 14th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. from ebaysdk.finding import Connection as finding
  2. from bs4 import BeautifulSoup
  3. import pandas as pd
  4. import traceback
  5.  
  6.  
  7. ID_APP = 'AlexBord-LastSold-PRD-33882c1d0-aad65283'
  8. df = pd.read_excel(open('/Users/alexandrubordei/Downloads/snacks-3.xlsx', 'rb'), sheet_name='Sheet2', usecols='B')
  9. #Keywords = " ".join(df['Description'])
  10. #Keywords = 'candy'
  11. Keywords = df
  12. #Keywords = df.iterrows()
  13.  
  14. api = finding(appid=ID_APP, config_file=None)
  15. solditemsonly = True
  16. listingtype = 'FixedPrice'
  17. condition = 'New'
  18. locatedin = 'US'
  19.  
  20. dct_completedrequest = {
  21. 'keywords': Keywords,
  22. 'itemFilter': [
  23. {'name': 'Condition', 'value': condition},
  24. {'name': 'SoldItemsOnly', 'value': solditemsonly},
  25. {'name': 'ListingType', 'value': listingtype},
  26. {'name': 'LocatedIn', 'value': locatedin},
  27. ]}
  28.  
  29. response = api.execute('findCompletedItems', dct_completedrequest)
  30. soup = BeautifulSoup(response.content, 'lxml')
  31. items = soup.find_all('item')
  32.  
  33.  
  34. for item in items:
  35. cat = item.categoryname.string.lower()
  36. title = item.title.string.lower()
  37. price = int(round(float(item.currentprice.string)))
  38. url = item.viewitemurl.string.lower()
  39.  
  40. print('________')
  41. print('cat:\n' + cat + '\n')
  42. print('title:\n' + title + '\n')
  43. print('price:\n' + str(price) + '\n')
  44. print('url:\n' + url + '\n')
  45. input()
  46.  
  47.  
  48.  
  49. #with open ('ebay_search_results.txt', 'a+') as f:
  50. # for _, row in df.iterrows():
  51. # response = api.execute('findCompletedItems', dct_completedrequest)
  52. # soup = BeautifulSoup(response.content, 'lxml')
  53. # items = soup.find_all('item')
  54. # f.write(('\n'.join(items) + '\n'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement