Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit013d7a4

Browse files
kumannajoshthecoder
authored andcommitted
Add ur1.ca service.
This commit introduces ur1.ca support. Since ur1.ca is a simplisticservice which doesn't offer many interfaces, the shortened URL isextracted by parsing the output HTML from the service. Suggestions forbetter implementation welcome.Signed-off-by: Joshua Roesslein <jroesslein@gmail.com>
1 parent6f5574b commit013d7a4

File tree

3 files changed

+465
-429
lines changed

3 files changed

+465
-429
lines changed

‎imports.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
fromrandomimportrandint
1010
importbase64
1111
fromgetpassimportgetpass
12+
importre
1213

1314
try:
1415
importjson

‎services/ur1ca.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Shorty
2+
## Copyright 2009 Kumar Appaiah
3+
## See LICENSE
4+
5+
## @url ur1.ca
6+
classUr1ca(Service):
7+
8+
defshrink(self,bigurl):
9+
resp=request('http://ur1.ca/',
10+
post_data=urlencode({'longurl':bigurl,'submit' :'Make it an ur1!'}))
11+
returned_data=resp.read()
12+
matched_re=re.search('Your ur1 is: <a href="(http://ur1.ca/[^"]+)">\\1',returned_data)
13+
ifmatched_re:
14+
returnmatched_re.group(1)
15+
else:
16+
raiseShortyError('Failed to shrink url')
17+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp