-
Notifications
You must be signed in to change notification settings - Fork 6
/
jarskjalftar-a-islandi-4-1706-1990.py
39 lines (34 loc) · 1.28 KB
/
jarskjalftar-a-islandi-4-1706-1990.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
29
30
31
32
33
34
35
36
37
38
import scraperwiki,re
from BeautifulSoup import BeautifulSoup
quake = {}
def scrape_skjalfta(url):
html = scraperwiki.scrape(url)
soup = BeautifulSoup(html)
soup.prettify()
table = soup.find ('table', { 'width' : '80%' })
tr = table.findAll('tr')
for tr in tr:
date = tr.findNext('td')
date_store = re.sub(" \d+:\d+","",date.text)
date_time = date.text
time = re.sub("\d+-\d+-\d+ ","",date.text)
location=date.findNext('td')
lat = location.text[:4]
lng = location.text[5:]
latlng = [lat,lng]
latlng_float= map(float, latlng)
size=location.findNext('td')
distance=size.findNext('td')
landmark=distance.findNext('td')
quake['date'] = date_store
quake['time'] = time
quake['date_time'] = date_time
quake['lat'] = lat
quake['lng'] = lng
quake['size'] = size.text
quake['distance'] = distance.text
quake['landmark'] = landmark.text
print quake
scraperwiki.datastore.save(["date_time"], quake, latlng=(latlng_float))
url = 'http://hraun.vedur.is/ja/ymislegt/storskjalf.html'
scrape_skjalfta(url)