write docstrings for pylint

This commit is contained in:
agatha 2024-04-13 20:30:45 -04:00
parent 3119af0c9f
commit 6c2db118da
2 changed files with 22 additions and 17 deletions

View File

@ -1,17 +0,0 @@
import re
import requests
def unshorten_twitter(url):
pattern = re.compile(r"<title>(.*?)<\/title>")
response = requests.get(
url=url,
headers={"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0"}
)
match = pattern.search(response.text)
if match:
return match.group(1)
else:
return None

View File

@ -0,0 +1,22 @@
"""Unshortening functions"""
import re
import requests
def unshorten_twitter(url):
"""Retrieve the actual URL behind a Twitter URL."""
pattern = re.compile(r"<title>(.*?)<\/title>")
response = requests.get(
url=url,
headers={
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0"
},
timeout=4
)
match = pattern.search(response.text)
if match:
return match.group(1)
return None