write docstrings for pylint
This commit is contained in:
parent
3119af0c9f
commit
6c2db118da
@ -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
|
|
22
server/src/unshorteners.py
Normal file
22
server/src/unshorteners.py
Normal 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
|
Loading…
Reference in New Issue
Block a user