MCPcopy
hub / github.com/PokemonGoF/PokemonGo-Bot / fetch_raw

Method fetch_raw

pokemongo_bot/cell_workers/sniper.py:35–52  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

33 return self.url
34
35 def fetch_raw(self):
36 some_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/52.0.2743.116 Safari/537.36'
37 response = requests.get(self.url, headers={'User-Agent': some_agent}, timeout=self.timeout)
38
39 results = response.json()
40
41 # If the results is a dict, retrieve the list from it by the given key. This will return a list afterall.
42 if isinstance(results, dict):
43 results = results.get(self.key, [])
44
45 # If results is STILL a dict (eg. each pokemon is its own dict), need to build data from nested json (example whereispokemon.net)
46 while isinstance(results,dict):
47 tmpResults = []
48 for key, value in results.iteritems():
49 tmpResults.append(value)
50 results = tmpResults
51
52 return results
53
54 def fetch(self):
55 pokemons = []

Callers 2

fetchMethod · 0.95
validateMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected