source: plinkpot/linkpot

Last change on this file was 35, checked in by simon, 17 years ago
  • Check the link before potting.
  • Property svn:executable set to *
File size: 560 bytes
RevLine 
[33]1#!/usr/bin/env python
2
3import urllib
4import re
5
[35]6
7def check_link(url):
8    # Get the URL to check it "works"
9    urllib.urlopen(url)
10
[33]11pot_re = re.compile(r'Your quick url is <a href="(http://linkpot.net/.*?)"')
12
13def 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
19if __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.