diff options
author | icoz <icoz.vt@gmail.com> | 2017-07-09 14:38:15 +0300 |
---|---|---|
committer | icoz <icoz.vt@gmail.com> | 2017-07-09 14:38:15 +0300 |
commit | 5aed67eb79e641ad633905066e9cf3d7093dc483 (patch) | |
tree | ff064f4754fb6b1f98dcd4e12b0ba3402bc52c08 | |
parent | dcc9d0802613c0c08a137977fed43f457dac1a26 (diff) |
user.py:
- изменена разметка на Хабрахабре, параметр "дата регистрации"
-rw-r--r-- | habr/user.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/habr/user.py b/habr/user.py index 323026e..e3e512c 100644 --- a/habr/user.py +++ b/habr/user.py @@ -113,11 +113,14 @@ class TMUser(object): def _parseUserpage(self): # print(self._doc) # check for BAN - if self._doc.xpath("//div[@class='main']/h1")[0].text.strip() == "Доступ закрыт": + val = self._doc.xpath("//div[@class='main']/h1") + if val and val[0].text.strip() == "Доступ закрыт": # maybe raise ERROR??? return p_tags = self._doc.xpath("//div[@class='user_profile']//ul[@id='people-tags']//a/span") - date_of_registration = self._doc.xpath("//div[@class='user_profile']//dd[@class='grey']")[0].text.strip() + # date_of_registration = self._doc.xpath("//div[@class='user_profile']//dd[@class='grey']")[0].text.strip() + tmp = self._doc.xpath("//div[@class='user_profile']//p[@class='profile-section__invited']") + date_of_registration = tmp[0].text.strip() if tmp else "" tmp = self._doc.xpath("//div[@class='user_profile']//dl[last()]/dd") date_of_last_login = tmp[0].text.strip() @@ -189,7 +192,8 @@ class TMUser(object): url = self._genFavoritesUrlByUser(self._username) doc = html.document_fromstring(requests.get(url).text) # check for BAN - if doc.xpath("//div[@class='main']/h1")[0].text.strip() == "Доступ закрыт": + val = self._doc.xpath("//div[@class='main']/h1") + if val and val[0].text.strip() == "Доступ закрыт": # maybe raise ERROR??? return out = dict() |