Skip to content

Commit ab43e13

Browse files
committed
Zoom on hover and shadows to cards
1 parent c31343f commit ab43e13

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

main/templates/main/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ <h1 class="text-center">Make your search</h1>
3636
</div>
3737
<hr>
3838
{% if items %}
39-
<div class="row">
39+
<div class="row items">
4040
{% for item in items %}
4141
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4 pb-2 d-flex align-items-stretch justify-content-center">
4242
<div class="card" style="width: 18rem;">
43-
<img class="card-img-top" src="{{ item.image }}" alt="Card image cap">
43+
<a href="{{item.link}" target="_blank"><img class="card-img-top" src="{{ item.image }}" alt="Card image cap"></a>
4444
<div class="card-body">
4545
<h5 class="card-title"><a href="{{item.link}}" target="_blank">{{ item.name }}</a></h5>
4646
<p class="card-text">{{ item.condition }}</p>

main/views.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ class Index(ListView):
99
context_object_name = "items"
1010
template_name = "main/index.html"
1111

12+
# 2. Pass queryset to templates
1213
def get_context_data(self, *args, **kwargs):
1314
context = super(Index, self).get_context_data(*args, **kwargs)
1415
context['queryset'] = self.queryset
1516
return context
16-
17+
18+
# 1. Get search form data, scrape results and pass it to queryset
1719
def get_queryset(self):
1820
base_url = "https://www.ebay.com/sch/parser.html?_from=R40&_nkw={item}&_ipg=25"
1921
prices_url = "&_udlo={price_low}&_udhi={price_high}"
@@ -38,12 +40,14 @@ def __init__(self, base_url=None):
3840
self.base_url = base_url
3941
self.queryset[:] = []
4042

43+
# Start scraping
4144
def run(self):
42-
4345
try:
46+
# 2. Create soup with make_soup method (bs = BeautifulSoup)
4447
bs = self.make_soup(self.base_url)
4548
if not bs.get('error'):
4649
rows = bs.find_all('div', class_="s-item__wrapper")[:10]
50+
# 2.1 Loop through soup rows and parse them with parse_rows method
4751
for parser in rows:
4852
self.parse_rows(parser)
4953
else:
@@ -52,6 +56,7 @@ def run(self):
5256
print(error)
5357
return self.queryset
5458

59+
# 3. Parse soup from make_soup method
5560
def parse_rows(self, parser):
5661
name = parser.find('h3', class_="s-item__title").text
5762
link = parser.find('a', class_="s-item__link").get('href')
@@ -63,6 +68,7 @@ def parse_rows(self, parser):
6368
image = soup.find('img', {'id': "icImg"}).get('src')
6469
self.queryset.append(dict(name=name,link=link,condition=condition,price=price,image=image))
6570

71+
# 1. Make soup method
6672
def make_soup(self, url):
6773
headers = {'Accept': '*/*',
6874
'Accept-Encoding': 'gzip, deflate, sdch',

static/css/style.css

+20-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ body {
77
margin: 0;
88
height: 100%;
99
background: rgb(12,17,98);
10-
background: linear-gradient(0deg, rgba(12,17,98,0.8550770650056898) 0%, rgba(9,9,121,0.8130602582830007) 6%, rgba(0,212,255,0.9251050762101716) 100%);
10+
background: linear-gradient(0deg, rgba(12,17,98,0.8550770650056898) 0%, rgba(9,9,121,0.8130602582830007) 6%, rgba(0,212,255,0.9251050762101716) 100%);
1111
background-repeat: no-repeat;
1212
background-attachment: fixed;
1313
}
@@ -35,3 +35,22 @@ h1, .price-range {
3535
font-family: 'Kalam', cursive;
3636
padding-top: 15px;
3737
}
38+
39+
.card {
40+
-webkit-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.75);
41+
-moz-box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.75);
42+
box-shadow: 3px 3px 5px 0px rgba(0,0,0,0.75);
43+
transition: all .5s ease;
44+
}
45+
46+
.card:hover {
47+
webkit-box-shadow: 3px 3px 8px 1px rgba(0,0,0,0.75);
48+
-moz-box-shadow: 3px 3px 8px 1px rgba(0,0,0,0.75);
49+
box-shadow: 3px 3px 8px 1px rgba(0,0,0,0.75);
50+
transform: scale(1.1);
51+
z-index: 999;
52+
}
53+
54+
.items {
55+
padding-bottom: 25px;
56+
}

static/js/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function startDictation() {
2525
}
2626
}
2727

28-
// remove URL parameters ?
28+
// remove URL parameters ?
2929
$(document).ready(function(){
3030
var uri = window.location.toString();
3131
if (uri.indexOf("?") > 0) {

0 commit comments

Comments
 (0)