Last change
on this file since 35 was
35,
checked in by simon, 17 years ago
|
- Check the link before potting.
|
-
Property svn:executable set to
*
|
File size:
560 bytes
|
Rev | Line | |
---|
[33] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import urllib |
---|
| 4 | import re |
---|
| 5 | |
---|
[35] | 6 | |
---|
| 7 | def check_link(url): |
---|
| 8 | # Get the URL to check it "works" |
---|
| 9 | urllib.urlopen(url) |
---|
| 10 | |
---|
[33] | 11 | pot_re = re.compile(r'Your quick url is <a href="(http://linkpot.net/.*?)"') |
---|
| 12 | |
---|
| 13 | def linkpot(url): |
---|
| 14 | post_data = urllib.urlencode({'url': url}) |
---|
| 15 | res = urllib.urlopen('http://linkpot.net/add/', post_data).read() |
---|
| 16 | pot = pot_re.search(res).group(1) |
---|
| 17 | return pot |
---|
| 18 | |
---|
| 19 | if __name__ == '__main__': |
---|
| 20 | import sys |
---|
[34] | 21 | try: |
---|
[35] | 22 | check_link(sys.argv[1]) |
---|
[34] | 23 | print linkpot(sys.argv[1]) |
---|
| 24 | except Exception: |
---|
| 25 | sys.exit(1) |
---|
Note: See
TracBrowser
for help on using the repository browser.