mirror of
https://github.com/Marketscrape/marketscrape-web.git
synced 2026-02-20 15:44:33 -05:00
💄 Added bootstrap style sheet
This commit is contained in:
@@ -20,7 +20,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = ''
|
||||
SECRET_KEY = 'django-insecure-@p4$8)=h7vd43=gg!vp+)+t&+^75(r9fsx29241=99%(!c'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
@@ -32,6 +32,8 @@ ALLOWED_HOSTS = []
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'scraper',
|
||||
'crispy_forms',
|
||||
'crispy_bootstrap5',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
@@ -118,6 +120,8 @@ USE_TZ = True
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap5'
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Marketscrape</title>
|
||||
<link href="https://bootswatch.com/5/darkly/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
{% extends 'scraper/base.html' %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<div>
|
||||
<div class="row mt-5">
|
||||
<div class="col-12 col-md-6 mx-md-auto">
|
||||
<h1>Marketscrape</h1>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
{{ form|crispy }}
|
||||
<button class="btn btn-primary" type="submit">Calculate</button>
|
||||
<input type="button" value="Reset" id="resetBtn" onClick="this.form.reset()" />
|
||||
<!--<input type="button" value="Reset" id="resetBtn" onClick="this.form.reset()" />-->
|
||||
</form>
|
||||
<p> <br> Introducing the ultimate tool for Facebook Marketplace shopping. Marketscrape uses advanced AI technology to analyze prices of the latest posts, quickly letting you know if the price is a good deal or if you should keep looking. Take the guesswork out of shopping and find the best deals with just a click.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
@@ -1,19 +1,17 @@
|
||||
{% extends 'scraper/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<div>
|
||||
<h1>Marketscrape</h1>
|
||||
<h3>The shortened_url is: {{ shortened_url }}</h3>
|
||||
<h3>The mobile_url is: {{ mobile_url }}</h3>
|
||||
<h3>The market_id is: {{ market_id }}</h3>
|
||||
<h3>The sentiment_rating is: {{ sentiment_rating }}</h3>
|
||||
<h3>The title is: {{ title }}</h3>
|
||||
<h3>The list price is: {{ list_price }}</h3>
|
||||
<h3>The initial price is: {{ initial_price }}</h3>
|
||||
<h3>lower bound: {{ lower_bound }}</h3>
|
||||
<h3>upper bound: {{ upper_bound }}</h3>
|
||||
<h3>median: {{ median }}</h3>
|
||||
<a href="{% url 'index' %}" class="btn btn-outline-primary mt-3 mx-3">Go Back</a>
|
||||
<h1 class="col-12 col-md-6 mx-md-auto">Marketscrape Analysis Report</h1>
|
||||
<div class="row mt-5">
|
||||
<div class="col-12 col-md-6 mx-md-auto">
|
||||
<h4> Product: {{ title }}</h4>
|
||||
<h4> Price: {{ list_price }}</h4>
|
||||
<h4> Range: ${{ lower_bound }} - ${{ upper_bound }}</h4>
|
||||
<h4> Median: ${{ median }}</h4>
|
||||
<h4> Description: {{ sentiment_rating }}/5.0</h4>
|
||||
<h4> Price: {{ price_rating }}/5.0</h4>
|
||||
<h4> Overall: {{ average_rating }}/5.0</h4>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
@@ -45,6 +45,10 @@ class Index(View):
|
||||
|
||||
lower_bound, upper_bound, median = self.find_viable_product(title, ramp_down=0.0)
|
||||
|
||||
# Calculate the price difference between the listing and the median price of the viable products, and generate ratings
|
||||
price_rating = self.price_difference_rating(initial_price, median)
|
||||
average_rating = statistics.mean([sentiment_rating, price_rating])
|
||||
|
||||
|
||||
context = {
|
||||
'shortened_url': shortened_url,
|
||||
@@ -57,9 +61,21 @@ class Index(View):
|
||||
'lower_bound': lower_bound,
|
||||
'upper_bound': upper_bound,
|
||||
'median': median,
|
||||
'price_rating': price_rating,
|
||||
'average_rating': average_rating,
|
||||
}
|
||||
return render(request, 'scraper/result.html', context)
|
||||
|
||||
def price_difference_rating(self, initial, final):
|
||||
# If the listing price is less than or equal to the median price found online, set the rating to 5
|
||||
if initial <= final:
|
||||
rating = 5.0
|
||||
else:
|
||||
# If the listing price is greater than the median price found online, calculate the difference
|
||||
difference = min(initial, final) / max(initial, final)
|
||||
rating = (difference / 20) * 100
|
||||
return rating
|
||||
|
||||
def find_viable_product(self, title, ramp_down):
|
||||
title = self.clean_listing_title(title)
|
||||
headers = {
|
||||
|
||||
Reference in New Issue
Block a user