From 0fde44d61a1ce1e094c73c64c39ff8d7b9b179cf Mon Sep 17 00:00:00 2001 From: alexwholland Date: Sat, 25 Feb 2023 19:21:21 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20Improved=20main=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- marketscrape/scraper/forms.py | 5 +- .../scraper/templates/scraper/index.html | 60 +++++++++++++++---- marketscrape/scraper/views.py | 10 ++-- 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/marketscrape/scraper/forms.py b/marketscrape/scraper/forms.py index 961f129..f93fdbd 100644 --- a/marketscrape/scraper/forms.py +++ b/marketscrape/scraper/forms.py @@ -1,4 +1,7 @@ from django import forms class MarketForm(forms.Form): - input_url = forms.URLField() \ No newline at end of file + url = forms.URLField(label=False, widget=forms.TextInput(attrs={ + 'class': 'form-control', + 'placeholder': 'Enter a Facebook Marketplace URL', + })) diff --git a/marketscrape/scraper/templates/scraper/index.html b/marketscrape/scraper/templates/scraper/index.html index afd6c2b..9cb1a99 100644 --- a/marketscrape/scraper/templates/scraper/index.html +++ b/marketscrape/scraper/templates/scraper/index.html @@ -2,16 +2,50 @@ {% load crispy_forms_tags %} {% block content %} -
-
-

Marketscrape

-
- {% csrf_token %} - {{ form|crispy }} - - -
-


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.

-
-
-{% endblock content %} \ No newline at end of file +
+

Marketscrape

+

Shop smarter with AI-driven analysis by Marketscrape

+
+
+
+ {% csrf_token %} +
+ {{ form }} +
+ + +
+
+
+
+

Search Results

+ + + + + + + + + + {% for result in results %} + + + + + + {% empty %} + + + + {% endfor %} + +
ItemScoreLink
{{ result.item }}{{ result.price }}{{ result.link }}
No results to display.
+
+
+ +
+
+
+
+{% endblock content %} diff --git a/marketscrape/scraper/views.py b/marketscrape/scraper/views.py index 8784e27..56ee66b 100644 --- a/marketscrape/scraper/views.py +++ b/marketscrape/scraper/views.py @@ -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))