mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Updated all URL shorteners to use requests library. Useful for proxy servers
This commit is contained in:
parent
cbbf1e475d
commit
f69e4283cd
@ -7,7 +7,6 @@ class AcortameShortener (URLShortener):
|
||||
super(AcortameShortener, self).__init__(*args, **kwargs)
|
||||
|
||||
def _shorten (self, url):
|
||||
|
||||
answer = url
|
||||
api = requests.get ("https://acorta.me/api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
if api.status_code == 200:
|
||||
|
@ -1,19 +1,18 @@
|
||||
import urllib
|
||||
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
|
||||
|
||||
class ClckruShortener (URLShortener):
|
||||
def __init__ (self, *args, **kwargs):
|
||||
self.name = "clck.ru"
|
||||
return super(ClckruShortener, self).__init__(*args, **kwargs)
|
||||
super(ClckruShortener, self).__init__(*args, **kwargs)
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = urllib.urlopen ("http://clck.ru/--?url=" + urllib.quote(url))
|
||||
if api.getcode() == 200:
|
||||
answer = api.read()
|
||||
api.close()
|
||||
api = requests.get ("http://clck.ru/--?url=" + urllib.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
||||
def created_url (self, url):
|
||||
|
@ -1,5 +1,5 @@
|
||||
import urllib
|
||||
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
|
||||
class HKCShortener (URLShortener):
|
||||
@ -9,10 +9,9 @@ class HKCShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = urllib.urlopen ("http://hkc.im/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
if api.getcode() == 200:
|
||||
answer = api.read()
|
||||
api.close()
|
||||
api = requests.get ("http://hkc.im/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
||||
def created_url (self, url):
|
||||
|
@ -1,19 +1,18 @@
|
||||
import urllib
|
||||
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
|
||||
|
||||
class IsgdShortener (URLShortener):
|
||||
def __init__ (self, *args, **kwargs):
|
||||
self.name = "Is.gd"
|
||||
return super(IsgdShortener, self).__init__(*args, **kwargs)
|
||||
super(IsgdShortener, self).__init__(*args, **kwargs)
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = urllib.urlopen ("http://is.gd/api.php?longurl=" + urllib.quote(url))
|
||||
if api.getcode() == 200:
|
||||
answer = api.read()
|
||||
api.close()
|
||||
api = requests.get ("http://is.gd/api.php?longurl=" + urllib.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
||||
def created_url (self, url):
|
||||
|
@ -1,5 +1,5 @@
|
||||
import urllib
|
||||
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
|
||||
class OnjmeShortener (URLShortener):
|
||||
@ -9,10 +9,9 @@ class OnjmeShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = urllib.urlopen ("http://onj.me/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
if api.getcode() == 200:
|
||||
answer = api.read()
|
||||
api.close()
|
||||
api = requests.get ("http://onj.me/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
||||
def created_url (self, url):
|
||||
|
@ -1,5 +1,5 @@
|
||||
import urllib
|
||||
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
|
||||
class TinyArrowsShortener (URLShortener):
|
||||
@ -9,8 +9,10 @@ class TinyArrowsShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
answer = urllib.urlopen("http://tinyarro.ws/api-create.php?utfpure=1&url=%s" % urllib.quote(url)).read()
|
||||
api = requests.get("http://tinyarro.ws/api-create.php?utfpure=1&url=%s" % urllib.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer.decode('UTF-8')
|
||||
|
||||
def created_url(self, url):
|
||||
return False
|
||||
return "tinyarro.ws" in url
|
||||
|
@ -1,4 +1,5 @@
|
||||
from url_shortener import URLShortener
|
||||
import requests
|
||||
import urllib
|
||||
class TinyurlShortener (URLShortener):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -6,12 +7,10 @@ class TinyurlShortener (URLShortener):
|
||||
super(TinyurlShortener, self).__init__(*args, **kwargs)
|
||||
|
||||
def _shorten (self, url):
|
||||
|
||||
answer = url
|
||||
api = urllib.urlopen ("http://tinyurl.com/api-create.php?url=" + urllib.quote(url))
|
||||
if api.getcode() == 200:
|
||||
answer = api.read()
|
||||
api.close()
|
||||
api = requests.get ("http://tinyurl.com/api-create.php?url=" + urllib.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
||||
def created_url (self, url):
|
||||
|
@ -1,5 +1,5 @@
|
||||
import urllib
|
||||
|
||||
import requests
|
||||
from url_shortener import URLShortener
|
||||
|
||||
class XedccShortener (URLShortener):
|
||||
@ -9,10 +9,9 @@ class XedccShortener (URLShortener):
|
||||
|
||||
def _shorten (self, url):
|
||||
answer = url
|
||||
api = urllib.urlopen ("http://xed.cc/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
if api.getcode() == 200:
|
||||
answer = api.read()
|
||||
api.close()
|
||||
api = requests.get ("http://xed.cc/yourls-api.php?action=shorturl&format=simple&url=" + urllib.quote(url))
|
||||
if api.status_code == 200:
|
||||
answer = api.text
|
||||
return answer
|
||||
|
||||
def created_url (self, url):
|
||||
|
Loading…
Reference in New Issue
Block a user