LL Golf Hole 1 - tinyurl.comを使ってURLを短縮する
Posted feedbacks - Python
lxml
1 2 3 4 5 6 7 | from urllib2 import urlopen
from lxml.html import parse, submit_form
form = parse(urlopen('http://tinyurl.com/')).getroot().forms[1]
form.fields['url'] = 'http://ll.jus.or.jp/2008/info/xgihyo'
root = parse(submit_form(form)).getroot()
print root.xpath('//blockquote/b')[1].text
|
see: ClientForm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import re
from urllib2 import urlopen
from ClientForm import ParseResponse
from htmllib import HTMLParser
from formatter import NullFormatter
response = urlopen('http://tinyurl.com/')
form = ParseResponse(response, False)[1]
form['url'] = 'http://ll.jus.or.jp/2008/info/xgihyo'
h = HTMLParser(NullFormatter())
h.feed(urlopen(form.click()).read())
h.close
r = re.compile(r'http://tinyurl.com/\w+')
for i in h.anchorlist:
if r.match(i):
print i
|


takano32
#6771()
[
Ruby
]
Rating-4/16=-0.25
tinyurl.com( http://tinyurl.com/ )のサービスを利用し、 http://ll.jus.or.jp/2008/info/xgihyo というURLを短縮しなさい。tinyurl.comのalias機能は使わないものとする。 なお、参考までに短縮したURLは http://tinyurl.com/5mngx8 となる。
余力のあるものはこのプログラムを短くしてみたり、短くしてみたり、短くしてみよ。
※LL Future実行委員の高野光弘です。この出題は LL Future公式の出題であり、優れたものについてはLL Golfのセッションでご紹介させていただくかもしれません。ご理解の上、ご投稿ください。また、LL Futureのチケットは現在も発売中です。よろしければ、メインイベントの方にもぜひご参加ください。
see: tinyurl.comでURLを短縮するRubyスクリプト
Rating-4/16=-0.25-0+
[ reply ]