-
Notifications
You must be signed in to change notification settings - Fork 1
/
cacheMaker.py
28 lines (22 loc) · 800 Bytes
/
cacheMaker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import mechanize
from BeautifulSoup import BeautifulSoup
sitemapUrl="http://www.raspberryweather.com/sitemap.xml" # REPLACE WITH YOUR OWN SITEMAP
parsedUrl=[] #contains urls from sitemap
browser=mechanize.Browser()
try:
print "Getting the sitemap"
response=browser.open(sitemapUrl)
except:
print "Something went wrong"
exit()
soup=BeautifulSoup(response)
for url in soup.findAll('loc'):
url=str(url)
url=url[5:] # i know i know, could be done nicer
parsedUrl.append(url[:len(url)-6])
#visit the sites and generate a cache
for url in parsedUrl:
print "Visiting: "+url
browser.open(url)
print "Done, cache created"
print "Finished, if you want to check, have a look at /wp-content/cache"