Skip to content

Commit

Permalink
Update search.py
Browse files Browse the repository at this point in the history
- Added minor changes to code. Had missed the list "matches".
- Added comments for dictionary comprehension.
  • Loading branch information
RDxR10 authored Oct 25, 2023
1 parent 76e6b7c commit cd8ca17
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions google_play_scraper/features/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ def search(
url = Formats.Searchresults.fallback_build(query=query, lang=lang)
dom = get(url)

matches = Regex.SCRIPT.findall(dom)
matches = Regex.SCRIPT.findall(dom) #take out script blocks from dom

dataset = {}

dataset = {key: json.loads(value) for key, value in zip(Regex.KEY.findall(match), Regex.VALUE.findall(match)) if key and value}
dataset = {key: json.loads(value) for match, key, value in zip(matches, Regex.KEY.findall(match), Regex.VALUE.findall(match)) if key and value}
"""
This is to create a dictionary "dataset" that would combine key-value pairs for each match obtained from matches under the condition that the key and value are non-empty.
The matches variable is a list of match objects returned by the Regex.SCRIPT.findall() function.
"""

success = False
# different idx for different countries and languages
Expand Down

0 comments on commit cd8ca17

Please sign in to comment.