Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ebaysdk.finding import Connection as finding
- from bs4 import BeautifulSoup
- import pandas as pd
- import traceback
- ID_APP = 'AlexBord-LastSold-PRD-33882c1d0-aad65283'
- df = pd.read_excel(open('/Users/alexandrubordei/Downloads/snacks-3.xlsx', 'rb'), sheet_name='Sheet2', usecols='B')
- #Keywords = " ".join(df['Description'])
- #Keywords = 'candy'
- Keywords = df
- #Keywords = df.iterrows()
- api = finding(appid=ID_APP, config_file=None)
- solditemsonly = True
- listingtype = 'FixedPrice'
- condition = 'New'
- locatedin = 'US'
- dct_completedrequest = {
- 'keywords': Keywords,
- 'itemFilter': [
- {'name': 'Condition', 'value': condition},
- {'name': 'SoldItemsOnly', 'value': solditemsonly},
- {'name': 'ListingType', 'value': listingtype},
- {'name': 'LocatedIn', 'value': locatedin},
- ]}
- response = api.execute('findCompletedItems', dct_completedrequest)
- soup = BeautifulSoup(response.content, 'lxml')
- items = soup.find_all('item')
- 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('________')
- print('cat:\n' + cat + '\n')
- print('title:\n' + title + '\n')
- print('price:\n' + str(price) + '\n')
- print('url:\n' + url + '\n')
- input()
- #with open ('ebay_search_results.txt', 'a+') as f:
- # for _, row in df.iterrows():
- # response = api.execute('findCompletedItems', dct_completedrequest)
- # soup = BeautifulSoup(response.content, 'lxml')
- # items = soup.find_all('item')
- # f.write(('\n'.join(items) + '\n'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement