Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ This repo contains scripts for the following sites:
- GOAT
- eBay
- Depop
- BUMP

## How to use

These scripts can be run via the command line.
The general structure is as follows

#### Windows
```
python [script name] [argument 1] [argument 2]
```

#### Linux/Mac
```
python3 [script name] [argument 1] [argument 2]
```

With most of the tools, you will only need to pass 1 argument, with the exception of `eBayBot.py` which takes 2.
An example of how to pass arguments is shown below:
```
Expand All @@ -47,3 +52,4 @@ An example is shown below:
```
python eBayBot.py current 'yeezy 350 creams'
```
including the single quotations around the item is important to the accuracy of your results.
38 changes: 0 additions & 38 deletions src/BumpBot.py

This file was deleted.

19 changes: 12 additions & 7 deletions src/DepopBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
def scrape_site(item):
current_listings = []
try:
url = f'https://webapi.depop.com/api/v1/search/?what={item.replace(" ", "%20")}&country=gb&limit=200'
#change country_code to your countries two letter code (eg. gb for great britain)
country_code = 'gb'
url = f'https://webapi.depop.com/api/v2/search/products/?what={item.replace(" ", "+")}&itemsPerPage=40&country={country_code}&sort=relevance'
html = rq.get(url=url)
output = json.loads(html.text)
for i in output['products']:
price = i['price']['price_amount']
price = i['price']['priceAmount']
current_listings.append(float(price))
return current_listings
except Exception as e:
Expand All @@ -28,11 +30,14 @@ def clean_data(data):


def summary_of_prices(data):
print('Max: ', max(data))
print('Min: ', min(data))
print('Average: ', sum(data) / len(data))
print('Standard Deviation: ', statistics.stdev(data))
print('Number of listings: ', len(data))
try:
print('Max: ', max(data))
print('Min: ', min(data))
print('Average: ', (sum(data) / len(data)).__round__(2))
print('Standard Deviation: ', statistics.stdev(data).__round__(2))
print('Number of listings: ', len(data))
except ValueError:
print('Not enough listings to calculate statistics')


if __name__ == '__main__':
Expand Down
15 changes: 9 additions & 6 deletions src/eBayBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def get_current_prices(item):
try:
current_listings.append(float(price.replace('£', '')))
except:
price = price.replace(' to', '').replace('£', '')
#replaces dollar sign and pound sign
price = price.replace(' to', '').replace('£', '').replace(',', '').replace('$', '')
price = price.split()
prices = [float(item) for item in price]
current_listings.append(statistics.mean(prices))
Expand All @@ -29,7 +30,9 @@ def get_sold_prices(item):
sold_listings = []

try:
url = f'https://www.ebay.co.uk/sch/i.html?_nkw={item.replace(" ", "+")}&_ipg=200&rt=nc&LH_Sold=1'
#to use USA ebay replace .co.uk with .com
base_url = 'https://www.ebay.co.uk'
url = f'{base_url}/sch/i.html?_nkw={item.replace(" ", "+")}&_ipg=200&rt=nc&LH_Sold=1'
html = rq.get(url=url)
soup = BeautifulSoup(html.text, 'html.parser')

Expand All @@ -38,7 +41,7 @@ def get_sold_prices(item):
try:
sold_listings.append(float(price.replace('£', '')))
except:
price = price.replace(' to', '').replace('£', '')
price = price.replace(' to', '').replace('£', '').replace(',', '').replace('$', '')
price = price.split()
sold_listings.append(statistics.mean([float(item) for item in price]))
return sold_listings
Expand All @@ -50,8 +53,8 @@ def get_sold_prices(item):
def summary_of_prices(data):
print('Max: ', max(data))
print('Min: ', min(data))
print('Average: ', sum(data) / len(data))
print('Standard Deviation: ', statistics.stdev(data))
print('Average: ', (sum(data) / len(data)).__round__(2))
print('Standard Deviation: ', statistics.stdev(data).__round__(2))
print('Number of listings: ', len(data))


Expand All @@ -67,4 +70,4 @@ def summary_of_prices(data):
if output != 'Exception' and output != []:
summary_of_prices(output)
else:
print('Please check second argument variable')
print('Please check second argument variable')