[twitter] improve 'http' -> 'https' replacement
This commit is contained in:
@@ -222,10 +222,12 @@ class TwitterExtractor(Extractor):
|
|||||||
url = url["expanded_url"]
|
url = url["expanded_url"]
|
||||||
if "//twitpic.com/" not in url or "/photos/" in url:
|
if "//twitpic.com/" not in url or "/photos/" in url:
|
||||||
continue
|
continue
|
||||||
resp = self.request(url.replace("http:", "https:", 1), fatal=False)
|
if url.startswith("http:"):
|
||||||
if resp.status_code >= 400:
|
url = "https" + url[4:]
|
||||||
|
response = self.request(url, fatal=False)
|
||||||
|
if response.status_code >= 400:
|
||||||
continue
|
continue
|
||||||
url = text.extr(resp.text, 'name="twitter:image" value="', '"')
|
url = text.extr(response.text, 'name="twitter:image" value="', '"')
|
||||||
if url:
|
if url:
|
||||||
files.append({"url": url})
|
files.append({"url": url})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user