def generate_sitemap(args):

	# init sitemap
	sm = Sitemap(changefreq='weekly')

	solr_handle = Solr('http://localhost:8080/solr4/fedobjs')
	query = {'q' : 'rels_isDiscoverable:True', 'fl' : 'id', 'start' : 0}

	# get solr cursor
	cursor = solr_handle.search_cursor(**query)

	# loop through and write to sitemap
	for chunk in cursor.fetch(100):
		for object_id in chunk.documents:
			urladd = "https://digital.library.wayne.edu/item/{object_id}".format(object_id=object_id)
			sm.add(
				urladd,
				lastmod="today"
			)

	# save to disk
	if args.output:
		filename = args.output
	else:
		filename = "/var/www/wsuls/digitalcollections/public/sitemaps/sitemap_https.xml"
	fhand = open(filename, "w")
	sm.write(fhand)
	fhand.close()
	print("sitemap created at %s, total time elapsed %s" % (filename, (time.time()-stime) ))
Esempio n. 2
0
def writeSitemapXML(id_list, smCount):
	sm = Sitemap(changefreq='weekly')
	for object_id in id_list:
		urladd = "http://digital.library.wayne.edu/item/{object_id}".format(object_id=object_id)
		sm.add(
			urladd,
			lastmod="today"
		)
	filename = "/var/www/wsuls/digitalcollections/sitemaps/sitemap{smCount}.xml".format(smCount=smCount)
	fhand = open(filename,"w")
	sm.write(fhand)
	fhand.close()
Esempio n. 3
0
def create_sitemap():
    sm = Sitemap(changefreq="daily")
    sm.add("http://" + config.base_url, lastmod="today")

    db = dataset.connect("sqlite:///leyes.db")
    res = db.query("SELECT * FROM proyectos ORDER BY timestamp DESC")
    for i in res:
        url = "http://" + config.base_url + "p/" + i['short_url']
        lastmod = str(datetime.datetime.fromtimestamp(int(i['timestamp'])))
        lastmod = lastmod.split(" ")[0]
        sm.add(url, lastmod=lastmod)

    for i in glob.glob(os.path.join(config.base_folder, "congresista/*")):
        i = os.path.basename(i)
        url = "http://" + config.base_url + "congresista/" + i + "/index.html"
        sm.add(url, lastmod="today")

    out = codecs.open("sitemap.xml", "w", "utf-8")
    sm.write(out)
    out.close()
def create_sitemap():
    sm = Sitemap(changefreq="daily")
    sm.add("http://" + config.base_url, lastmod="today")
    
    
    db = dataset.connect("sqlite:///leyes.db")
    res = db.query("SELECT * FROM proyectos ORDER BY timestamp DESC")
    for i in res:
        url = "http://" + config.base_url + "p/" + i['short_url']
        lastmod = str(datetime.datetime.fromtimestamp(int(i['timestamp'])))
        lastmod = lastmod.split(" ")[0]
        sm.add(url, lastmod=lastmod)


    for i in glob.glob(os.path.join(config.base_folder, "congresista/*")):
        i = os.path.basename(i)
        url = "http://" + config.base_url + "congresista/" + i + "/index.html"
        sm.add(url, lastmod="today")
    
    
    out = codecs.open("sitemap.xml", "w", "utf-8")
    sm.write(out)
    out.close()
Esempio n. 5
0
def build_sitemap():
    from redberry.models import RedPost, RedCategory
    from apesmit import Sitemap
    sm = Sitemap(changefreq='weekly')

    for post in RedPost.all_published():
        sm.add(url_for('redberry.show_post', slug=post.slug, _external=True),
               lastmod=post.updated_at.date())

    for category in RedCategory.query.all():
        sm.add(url_for('redberry.show_category',
                       category_slug=category.slug,
                       _external=True),
               lastmod=category.updated_at.date())

    with open(os.path.join(REDBERRY_ROOT, 'static', 'redberry', 'sitemap.xml'),
              'w') as f:
        sm.write(f)

    flash("Sitemap created.", 'success')
    return redirect(url_for('redberry.home'))
Esempio n. 6
0
#!/usr/bin/env python2
# coding: utf-8
from apesmit import Sitemap
'''
http://python-3.ru/page/generate-sitemap-xml-in-python
'''
# Ставим значение частоты изменении для всех ссылок
# sm = Sitemap(changefreq='weekly')
sm = Sitemap(changefreq='monthly')

# Добавляем обычную сссылку, указываем индивидульно приоритет
sm.add('http://blog.dtulyakov.ru/', priority=1.0)
# Добавляем ссылку с измененым параметром последнего изменения
# sm.add('http://python-3.ru/page/send-sms-python', lastmod='today')

# sm.add('http://python-3.ru/category/sqlite', changefreq='daily', priority=1.0, lastmod='2015-07-23')

# Создаем файл sitemap в текущею папку скрипта
out = open('sitemap.xml', 'w')
# записываем данные
sm.write(out)
# закрываем файл
out.close()
Esempio n. 7
0
#! /usr/bin/python2.7

# Peter Novotnak::Flexion INC, 2012


from apesmit import Sitemap
from sys     import stdin, argv

path = argv[1]

sm = Sitemap( changefreq='weekly' )

for line in stdin:
    sm.add( str(line).strip(),
            lastmod='today')


out=open(str(path)+'/sitemap.xml', 'w')
sm.write(out)
out.close()