示例#1
0
def fetch_new_images():
	html = _fetch()
	posts = html.findAll('a', 'title')
	new_images = []
	for post in posts:
		url = post.attrMap['href']
		url_parts = split_url(url)
		if re.match('^.+\.imgur\.com', url_parts.netloc): # we only want to pull images from imgur
			if url[-4:] not in ['.jpg', '.png']: # make sure we're pulling the image, not the HTML page
				continue
			new_images.append({'title': post.text, 'href': url, 'filename': _get_filename_from_url(url)})
	_cache_images(new_images)
	return new_images 
示例#2
0
def fetch_new_images():
    html = _fetch()
    posts = html.findAll('a', 'title')
    new_images = []
    for post in posts:
        url = post.attrMap['href']
        url_parts = split_url(url)
        if re.match(
                '^.+\.imgur\.com',
                url_parts.netloc):  # we only want to pull images from imgur
            if url[-4:] not in [
                    '.jpg', '.png'
            ]:  # make sure we're pulling the image, not the HTML page
                continue
            new_images.append({
                'title': post.text,
                'href': url,
                'filename': _get_filename_from_url(url)
            })
    _cache_images(new_images)
    return new_images
示例#3
0
def _get_filename_from_url(url):
	return split_url(url).path.split('/')[-1:][0]
示例#4
0
def _get_filename_from_url(url):
    return split_url(url).path.split('/')[-1:][0]