麻辣博士谈军事,海神谜咒套,外交部提醒暂勿赴菲
beautiful photo!: http://www.beautifulphoto.net/
_random_url = r'http://www.beautifulphoto.net/plugin/rndarticle/'
_img_patt = re.compile(r'<img src="http://www\.beautifulphoto\.net/upload/(\d+)\.jpg" />')
def random(timeout=3, more=false):
try:
html = urllib2.urlopen(_random_url, timeout=timeout).read()
except urllib2.urlerror, e:
return none
res = re.search(_img_patt, html)
if res:
name = res.group(1)
if more:
return 'http://www.beautifulphoto.net/upload/', '%s_mini.jpg' % name, '%s.jpg' % name
return 'http://www.beautifulphoto.net/upload/%s_mini.jpg' % name
return none
if __name__ == '__main__':
url = random()
print(url)
if url:
import webbrowser as wb
wb.open(url)
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
python求numpy中array按列非零元素的平均值案例
网友评论