@@ -383,26 +383,17 @@ def _cache_from_guid(self, guid):
383383 return Cache ._from_print_page (self , guid , print_page )
384384
385385 def _try_getting_cache_from_guid (self , guid ):
386- """tries to read a geocache from GUID page
387- if this is not possible (because it's a premium only cache) it reads the cache from the GC code"""
386+ """Try to get a cache from guid page if possible, otherwise from gccode.
387+
388+ :param str guid: guid of the cache that should be read in
389+ """
388390 try :
389391 return self .get_cache (guid = guid )
390392 except PMOnlyException :
391- url = "https://www.geocaching.com/seek/ cache_details.aspx?guid={}" . format ( guid )
392- wp = self . _get_gccode_from_guidpage ( url )
393+ url = self . _request ( Cache . _urls [ " cache_details" ], params = { " guid" : guid }, expect = "raw" ). url
394+ wp = url . split ( "/" )[ 4 ]. split ( "_" )[ 0 ] # get gccode from redirected url
393395 return self .get_cache (wp )
394396
395- @staticmethod
396- def _get_gccode_from_guidpage (url ):
397- data = requests .get (url ).text
398- soup = bs4 .BeautifulSoup (data , features = "html.parser" )
399- gc_element = soup .find ("li" , class_ = "li__gccode" )
400- if gc_element is not None : # PMonly caches, this it what this function is for
401- gccode = gc_element .text .strip ()
402- else :
403- gccode = soup .find ("span" , class_ = "CoordInfoCode" ).text .strip ()
404- return gccode
405-
406397 def my_logs (self , log_type = None , limit = float ('inf' )):
407398 """Get an iterable of the logged-in user's logs.
408399
0 commit comments