mirror of
https://github.com/Marketscrape/marketscrape-web.git
synced 2026-05-24 21:54:29 -04:00
@@ -1,4 +1,7 @@
|
||||
from django import forms
|
||||
|
||||
class MarketForm(forms.Form):
|
||||
input_url = forms.URLField()
|
||||
url = forms.URLField(label=False, widget=forms.TextInput(attrs={
|
||||
'class': 'form-control',
|
||||
'placeholder': 'Enter a Facebook Marketplace URL',
|
||||
}))
|
||||
|
||||
@@ -2,16 +2,50 @@
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row mt-5">
|
||||
<div class="col-12 col-md-6 mx-md-auto">
|
||||
<h1>Marketscrape</h1>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
<button class="btn btn-primary" type="submit">Calculate</button>
|
||||
<!--<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 %}
|
||||
<div class="container-lg mt-5">
|
||||
<h1 class="text-center mb-4">Marketscrape</h1>
|
||||
<p class="text-center mb-4">Shop smarter with AI-driven analysis by Marketscrape</p>
|
||||
<div class="row">
|
||||
<div class="col-md-8 mx-auto">
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
<div class="input-group">
|
||||
{{ form }}
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" type="submit">Calculate</button>
|
||||
<button class="btn btn-primary" type="button" value="Reset" id="resetBtn" onClick="this.form.reset()">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="mt-5">
|
||||
<h3 class="text-center">Search Results</h3>
|
||||
<table class="table table-striped mx-auto">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Item</th>
|
||||
<th>Score</th>
|
||||
<th>Link</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for result in results %}
|
||||
<tr>
|
||||
<td>{{ result.item }}</td>
|
||||
<td>{{ result.price }}</td>
|
||||
<td><a href="{{ result.link }}" target="_blank">{{ result.link }}</a></td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">No results to display.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="text-center mt-5">
|
||||
<a href="https://github.com/alexwholland" target="_blank"><i class="fab fa-github fa-3x"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
@@ -24,20 +24,20 @@ class Index(View):
|
||||
form = MarketForm(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
input_url = form.cleaned_data['input_url']
|
||||
url = form.cleaned_data['url']
|
||||
|
||||
# Shorten the URL listing to the title of the listing
|
||||
shortened_url = re.search(r".*[0-9]", input_url).group(0)
|
||||
shortened_url = re.search(r".*[0-9]", url).group(0)
|
||||
# Use the shortened URL and convert it to mobile, to get the price of the listing
|
||||
mobile_url = shortened_url.replace("www", "m")
|
||||
# Find the ID of the product
|
||||
market_id = (re.search(r"\/item\/([0-9]*)", input_url)).group(1)
|
||||
market_id = (re.search(r"\/item\/([0-9]*)", url)).group(1)
|
||||
|
||||
# Get the sentiment rating of the listing
|
||||
sentiment_rating = self.sentiment_analysis(self.get_listing_description(self.create_soup(input_url, headers=None)))
|
||||
sentiment_rating = self.sentiment_analysis(self.get_listing_description(self.create_soup(url, headers=None)))
|
||||
|
||||
# Get the title of the listing
|
||||
title = self.get_listing_title(self.create_soup(input_url, headers=None))
|
||||
title = self.get_listing_title(self.create_soup(url, headers=None))
|
||||
|
||||
# Get the minimum, maximum, and median prices of the viable products found on Google Shopping
|
||||
list_price = self.get_listing_price(self.create_soup(mobile_url, headers=None))
|
||||
|
||||
Reference in New Issue
Block a user