mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-03-26 23:46:46 +00:00
Merge remote-tracking branch 'gitlab/master'
# Conflicts: # twoot.py
This commit is contained in:
commit
65b3065a75
7
twoot.py
7
twoot.py
@ -216,13 +216,14 @@ def main(argv):
|
|||||||
if m is not None:
|
if m is not None:
|
||||||
link_url = m.group(0)
|
link_url = m.group(0)
|
||||||
try:
|
try:
|
||||||
r = requests.get(link_url)
|
r = requests.get(link_url, timeout=10)
|
||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
# Matches the first instance of either twitter:image or twitter:image:src meta tag
|
# Matches the first instance of either twitter:image or twitter:image:src meta tag
|
||||||
match = re.search(r'<meta name="twitter:image(?:|:src)" content="(.+?)".*?>', r.text)
|
match = re.search(r'<meta name="twitter:image(?:|:src)" content="(.+?)".*?>', r.text)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
photos.append(match.group(1))
|
url = match.group(1).replace('&', '&') # Remove HTML-safe encoding from URL if any
|
||||||
except (ConnectionError, requests.exceptions.ContentDecodingError):
|
photos.append(url)
|
||||||
|
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Add dictionary with content of tweet to list
|
# Add dictionary with content of tweet to list
|
||||||
|
Loading…
x
Reference in New Issue
Block a user