|
|
@@ -30,6 +30,11 @@ def run_single(conn, pid, check_bad_urls=False):
|
|
|
|
|
|
raw_json, price, lat, lon, size, ber, address, property_type, bathrooms, bedrooms = rows[0]
|
|
|
|
|
|
+ price = int(price) if price is not None else price
|
|
|
+ size = int(size) if size is not None else size
|
|
|
+ bedrooms = int(bedrooms) if bedrooms is not None else bedrooms
|
|
|
+ bathrooms = int(bathrooms) if bathrooms is not None else bathrooms
|
|
|
+
|
|
|
data = json.loads(raw_json)
|
|
|
|
|
|
search_rows = conn.select('select time, price from search_results where property_id=? order by time asc', pid)
|
|
|
@@ -42,17 +47,28 @@ def run_single(conn, pid, check_bad_urls=False):
|
|
|
<style>
|
|
|
img {width: 900px}
|
|
|
td {padding-right: 20px}
|
|
|
+
|
|
|
+ #top {
|
|
|
+ position: fixed;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ z-index: 999;
|
|
|
+ width: 100%;
|
|
|
+ height: 23px;
|
|
|
+ }
|
|
|
</style>
|
|
|
''')
|
|
|
f.write('<h2>%s</h2>\n' % address)
|
|
|
|
|
|
+ # f.write('<div id="top">')
|
|
|
f.write('<h2>')
|
|
|
- f.write('<span style="background-color: %s">%sk</span>, ' % (_color(ranking.r_price(int(price)/1000)), int(price/1000)))
|
|
|
- f.write('<span style="background-color: %s">%s m<sup>2</sup></span>, ' % (_color(ranking.r_size(int(size))), size))
|
|
|
- f.write('<span style="background-color: %s">%s br</span> / ' % (_color(ranking.r_bedrooms(int(bedrooms))), bedrooms))
|
|
|
- f.write('<span style="background-color: %s">%s b</span>, ' % (_color(ranking.r_bathrooms(int(bathrooms))), bathrooms))
|
|
|
+ f.write('<span style="background-color: %s">%sk</span>, ' % (_color(ranking.r_price(price/1000)), int(price/1000)))
|
|
|
+ f.write('<span style="background-color: %s">%s m<sup>2</sup></span>, ' % (_color(ranking.r_size(size)), size))
|
|
|
+ f.write('<span style="background-color: %s">%s br</span> / ' % (_color(ranking.r_bedrooms(bedrooms)), bedrooms))
|
|
|
+ f.write('<span style="background-color: %s">%s b</span>, ' % (_color(ranking.r_bathrooms(bathrooms)), bathrooms))
|
|
|
f.write('<span style="background-color: %s">%s</span>' % (_color(ranking.r_ber(ber)), ber))
|
|
|
f.write('</h2><br>\n')
|
|
|
+ # f.write('</div>')
|
|
|
|
|
|
f.write('<a href="https://www.myhome.ie/_/brochure/_/%i">myhome.ie</a>' % pid)
|
|
|
f.write(', <a href="https://www.google.ie/maps/search/%s">maps.ie</a>' % address)
|
|
|
@@ -61,7 +77,7 @@ def run_single(conn, pid, check_bad_urls=False):
|
|
|
f.write('<p><hr><p>')
|
|
|
f.write('<table><tr><td><b>Time</b></td><td><b>Price</b></td></tr>')
|
|
|
for ts, price in search_rows:
|
|
|
- f.write('<tr><td>%s</td><td>%s</td></tr>' % (ts, int(int(price)/1000) if price != 'GONE' else price))
|
|
|
+ f.write('<tr><td>%s</td><td>%s</td></tr>' % (ts, int(int(price)/1000) if price and price.isdigit() else price))
|
|
|
f.write('</table>')
|
|
|
|
|
|
f.write('<p><hr><p>')
|
|
|
@@ -152,10 +168,11 @@ def _get_pid(conn, possible_pid):
|
|
|
if __name__ == '__main__':
|
|
|
with db.connect() as conn:
|
|
|
if len(sys.argv) > 1:
|
|
|
- pid = int(sys.argv[1])
|
|
|
- pid = _get_pid(conn, pid)
|
|
|
- fname = run_single(conn, pid, check_bad_urls=True)[0]
|
|
|
- webbrowser.open('htmls/%i.html' % pid)
|
|
|
+ for pid in sys.argv[1:]:
|
|
|
+ pid = int(pid)
|
|
|
+ pid = _get_pid(conn, pid)
|
|
|
+ fname = run_single(conn, pid, check_bad_urls=True)[0]
|
|
|
+ webbrowser.open('htmls/%i.html' % pid)
|
|
|
else:
|
|
|
fname = run(conn)
|
|
|
webbrowser.open('htmls/index.html')
|