Skip to content

Commit

Permalink
Merge pull request #7 from CrypticGuy/vasugoel/updatedResponseHandle
Browse files Browse the repository at this point in the history
Fixed the error in code for getting the src attribute
  • Loading branch information
CrypticGuy authored Aug 31, 2024
2 parents 40ccc0c + d5b7cca commit 43541e5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/pyigdl/igdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@ def _parseResponse(response):
parsed_response = json.loads(parsed_response)['data']
except Exception as e:
parsed_response = response.json()['data']

if not ("download-items" in parsed_response):
parsed_response = extractHtmlContentFromJsResponse(parsed_response)

print(parsed_response)
selector = Selector(text=parsed_response)
download_data = []
for elem in selector.css(".download-items"):
thumbnail_selector = elem.css(".download-items__thumb > img")
if thumbnail_selector.attrib.get('class', '') == 'lazy':
thumbnail_link = thumbnail_selector.attrib.get('data-src', "Not found")
else:
thumbnail_link = thumbnail_selector.attrib('src', "Not found")
thumbnail_link = thumbnail_selector.attrib.get('src', "Not found")
download_data.append({
"thumbnail_link": thumbnail_link,
"download_link": elem.css(".download-items__btn > a").attrib.get("href", "")
Expand Down

0 comments on commit 43541e5

Please sign in to comment.