getting post title
This commit is contained in:
parent
5fe4b1f786
commit
7593b68b6c
@ -74,10 +74,38 @@ class WPMenu:
|
||||
except Exception as err:
|
||||
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, canalblog, err))
|
||||
|
||||
def _getIdfromTitlePost(self, content):
|
||||
idMenu = 0
|
||||
|
||||
return idMenu
|
||||
|
||||
def _getIdFromPost(self, href):
|
||||
idMenu = 0
|
||||
o = urlparse(href)
|
||||
if len(o.netloc) > 0:
|
||||
try:
|
||||
page = self._request_canalblog.get(href)
|
||||
if page.status_code == 200:
|
||||
self._logger.info("{0} : Get content : {1}".format(self._name, href))
|
||||
self._getIdfromTitlePost(page.content)
|
||||
else:
|
||||
self._logger.error("{0} : {2} didn't get due status code : {1}".format(self._name, page.status_code, i))
|
||||
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
||||
except ConnectionError as err:
|
||||
self._logger.error("{0} : Connection error for get url {1} : {2}".format(self._name, href, err))
|
||||
exit(1)
|
||||
except Exception as err:
|
||||
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, href, err))
|
||||
else:
|
||||
if os.path.exists("{0}/..{1}".format(self._directory, o.path)):
|
||||
try:
|
||||
content = open("{0}/..{1}".format(self._directory, o.path), "r")
|
||||
self._getIdfromTitlePost(content)
|
||||
except Exception as err:
|
||||
self._logger.error("{0} : Exception error for get file content {1} : {2}".format(self._name, href, err))
|
||||
return idMenu
|
||||
|
||||
|
||||
def _getIdFromReverse(self, title, href):
|
||||
self._logger.info("{0} : get title {1} from href {2}".format(self._name, title, href))
|
||||
idMenu = 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user