@@ -34,7 +34,7 @@ class Geocaching(object):
34
34
35
35
_urls = {
36
36
"login_page" : _baseurl + "login/default.aspx" ,
37
- "cache_details" : _baseurl + "seek/cache_details.aspx " ,
37
+ "cache_details" : _baseurl + "geocache/{wp} " ,
38
38
"caches_nearest" : _baseurl + "seek/nearest.aspx" ,
39
39
"geocode" : _baseurl + "api/geocode" ,
40
40
"map" : _tile_url + "map.details" ,
@@ -223,11 +223,12 @@ def _search_parse_cache(self, root):
223
223
c = Cache (wp , self )
224
224
225
225
# prettify data
226
- c .cache_type = typeLink .find ("img" ).get ("alt" )
226
+ c .cache_type = typeLink .find ("img" ).get (
227
+ "src" ).split ("/" )[- 1 ].rsplit ("." , 1 )[0 ] # filename of img[src]
227
228
c .name = nameLink .span .text .strip ()
228
229
c .found = found
229
230
c .state = "Strike" not in nameLink .get ("class" )
230
- c .size = " " . join ( size .get ("alt " ).split ()[ 1 :])
231
+ c .size = size .get ("src " ).split ("/" )[ - 1 ]. rsplit ( "." , 1 )[ 0 ] # filename of img[src]
231
232
c .difficulty , c .terrain = list (map (float , D_T .text .split ("/" )))
232
233
c .hidden = Util .parse_date (placed .text )
233
234
c .author = author [3 :] # delete "by "
@@ -454,10 +455,7 @@ def load_cache(self, wp, destination=None):
454
455
assert type (wp ) is str and wp .startswith ("GC" )
455
456
logging .info ("Loading details about %s..." , wp )
456
457
457
- # assemble request
458
- params = urlencode ({"wp" : wp })
459
- url = self ._urls ["cache_details" ] + "?" + params
460
-
458
+ url = self ._urls ["cache_details" ].format (wp = wp )
461
459
try :
462
460
root = self ._browser .get (url ).soup
463
461
except requests .exceptions .ConnectionError as e :
@@ -472,7 +470,7 @@ def load_cache(self, wp, destination=None):
472
470
473
471
# parse raw data
474
472
name = cache_details .find ("h2" )
475
- cache_type = cache_details .find ("img" ).get ("alt " )
473
+ cache_type = cache_details .find ("img" ).get ("src " )
476
474
author = cache_details ("a" )[1 ]
477
475
hidden = cache_details .find ("div" , "minorCacheDetails" ).find_all ("div" )[1 ]
478
476
location = root .find (id = "uxLatLon" )
@@ -491,14 +489,14 @@ def load_cache(self, wp, destination=None):
491
489
492
490
# prettify data
493
491
c .name = name .text
494
- c .cache_type = cache_type
492
+ c .cache_type = cache_type . split ( "/" )[ - 1 ]. rsplit ( "." , 1 )[ 0 ]
495
493
c .author = author .text
496
- c .hidden = Util .parse_date (hidden .text .split ()[ 2 ])
494
+ c .hidden = Util .parse_date (hidden .text .split (":" )[ - 1 ])
497
495
c .location = Point .from_string (location .text )
498
496
c .state = state is None
499
497
c .found = found and "Found It!" in found .text or False
500
498
c .difficulty , c .terrain = [float (_ .get ("alt" ).split ()[0 ]) for _ in D_T ]
501
- c .size = " " . join ( size .get ("alt " ).split ()[ 1 :])
499
+ c .size = size .get ("src " ).split ("/" )[ - 1 ]. rsplit ( "." , 1 )[ 0 ] # filename of img[src]
502
500
attributes_raw = [_ .get ("src" ).split ('/' )[- 1 ].rsplit ("-" , 1 ) for _ in attributes_raw ]
503
501
c .attributes = {attribute_name : appendix .startswith ("yes" )
504
502
for attribute_name , appendix in attributes_raw if not appendix .startswith ("blank" )}
0 commit comments