相思资源网 Design By www.200059.com

Beautiful Photo!: http://www.beautifulphoto.net/

复制代码 代码如下:
import urllib2
import re

_random_url = r'http://www.beautifulphoto.net/plugin/RndArticle/'
_img_patt = re.compile(r'<img src="/UploadFiles/2021-04-08/(\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)

标签:
随机某图,beautifulphoto

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“python获取beautifulphoto随机某图片代码实例”

暂无python获取beautifulphoto随机某图片代码实例的评论...