Skip to content

Commit

Permalink
Merge fa9105b into 72d3d92
Browse files Browse the repository at this point in the history
  • Loading branch information
Em-jey committed Nov 22, 2017
2 parents 72d3d92 + fa9105b commit 4c7d5c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
]
Expand Down
11 changes: 11 additions & 0 deletions morizon/offer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import datetime as dt
import json

import re

from bs4 import BeautifulSoup
Expand Down Expand Up @@ -209,6 +211,13 @@ def get_voivodeship_for_offer(item, *args, **kwargs):
return replace_all(nav[3], {' ': ''})


def get_meta_data(markup):
data = str(markup).split('__layer.push({"property":')[1].split(',"company":')[0]
print(data)
data = json.loads(data)
return data


def get_offer_data(url):
""" Parse data from offer page url
Expand All @@ -218,8 +227,10 @@ def get_offer_data(url):
:rtype: dict
"""
markup = BeautifulSoup(get_content_from_source(url), 'html.parser')
meta_data = get_meta_data(markup)

return {
'id': meta_data.get('id'),
'price': get_price_for_offer(markup),
'surface': get_surface_for_offer(markup),
'rooms': get_rooms_for_offer(markup),
Expand Down
2 changes: 1 addition & 1 deletion morizon/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def encode_text_to_url(text):
:param text: raw text
:type text: str
:return: encoded text which can be used in url
:rtpe: str
:rtype: str
"""
replace_dict = POLISH_CHARACTERS_MAPPING
replace_dict.update({' ': '-'})
Expand Down
2 changes: 0 additions & 2 deletions test_data/output.json

This file was deleted.

0 comments on commit 4c7d5c5

Please sign in to comment.