diff path network
This commit is contained in:
parent
f01a69a1e7
commit
04da5bc5f6
@ -445,21 +445,27 @@ class WPimport:
|
|||||||
if len(img) > 0:
|
if len(img) > 0:
|
||||||
href_a = i.get("href")
|
href_a = i.get("href")
|
||||||
href_img = img[0].get("src")
|
href_img = img[0].get("src")
|
||||||
|
href_a_o = urlparse(href_a)
|
||||||
|
href_img_o = urlparse(href_img)
|
||||||
new_img["old_src"]=href_img
|
new_img["old_src"]=href_img
|
||||||
new_img["old_href"]=href_a
|
new_img["old_href"]=href_a
|
||||||
try:
|
try:
|
||||||
page_img = self._request.get(href_img)
|
if len(href_img_o.netloc) > 0:
|
||||||
|
page_img = self._request.get(href_img)
|
||||||
|
|
||||||
if page_img.status_code == 404:
|
if page_img.status_code == 404:
|
||||||
href_img = href_a
|
href_img = href_a
|
||||||
try:
|
try:
|
||||||
page_img = self._request.get(href_a)
|
page_img = self._request.get(href_a)
|
||||||
except ConnectionError as err:
|
except ConnectionError as err:
|
||||||
self._logger.error("{0} : Connection error for get image : {1}".format(self._name, err))
|
self._logger.error("{0} : Connection error for get image : {1}".format(self._name, err))
|
||||||
exit(1)
|
exit(1)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
self._logger.error("{0} : Exception error for get image : {1}".format(self._name, err))
|
self._logger.error("{0} : Exception error for get image : {1}".format(self._name, err))
|
||||||
exit(1)
|
exit(1)
|
||||||
|
else:
|
||||||
|
if os.path.exists(href_img):
|
||||||
|
page_img = open(href_img, "r")
|
||||||
self._logger.debug("{0} : Status code for image {1} : {2}".format(self._name, href_img, page_img.status_code))
|
self._logger.debug("{0} : Status code for image {1} : {2}".format(self._name, href_img, page_img.status_code))
|
||||||
if page_img.status_code == 200:
|
if page_img.status_code == 200:
|
||||||
media=self._addOrUpdateMedia(href_img, page_img)
|
media=self._addOrUpdateMedia(href_img, page_img)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user