Skip to content

Commit

Permalink
fix: url error when getting data
Browse files Browse the repository at this point in the history
  • Loading branch information
pruizlezcano committed Aug 31, 2023
1 parent 7a17bf8 commit 39b9d62
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/comicgeeks/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
from bs4 import BeautifulSoup

from comicgeeks.extract import extract
from comicgeeks.utils import get_characters, get_series

from comicgeeks.utils import get_characters, get_series, randomword

class Issue:
None
Expand Down Expand Up @@ -809,7 +808,7 @@ def variant_covers(self) -> list:

def _get_data(self):
"""Get series info"""
url = f"https://leagueofcomicgeeks.com/comic/{self.issue_id}/foo"
url = f"https://leagueofcomicgeeks.com/comic/{self.issue_id}/{randomword(10)}"
r = self._session.get(url)
r.raise_for_status()
soup = BeautifulSoup(r.content, features="lxml")
Expand Down Expand Up @@ -1248,7 +1247,7 @@ def url(self, value):
self._url = value

def _get_data(self):
url = f"https://leagueofcomicgeeks.com/people/{self.creator_id}/foo"
url = f"https://leagueofcomicgeeks.com/people/{self.creator_id}/{randomword(10)}"
r = self._session.get(url)
r.raise_for_status()
comics_url = f"{r.url}/comics"
Expand Down Expand Up @@ -1466,7 +1465,7 @@ def character_id(self) -> str:
return self._character_id

def _get_data(self):
url = f"https://leagueofcomicgeeks.com/character/{self.character_id}/foo"
url = f"https://leagueofcomicgeeks.com/character/{self.character_id}/{randomword(10)}"
r = self._session.get(url)
r.raise_for_status()
comics_url = f"{r.url}/comics"
Expand Down
8 changes: 7 additions & 1 deletion src/comicgeeks/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import requests
import random
import string


def get_characters(content, Character, session: requests.Session):
Expand Down Expand Up @@ -40,6 +42,10 @@ def get_series(content, Series, session: requests.Session):


def is_trade_paperback(issue_id: int):
url = f"https://leagueofcomicgeeks.com/comic/{issue_id}/foo"
url = f"https://leagueofcomicgeeks.com/comic/{issue_id}/{randomword(10)}"
r = requests.get(url)
return r.url[-3:] == "-tp"

def randomword(length):
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(length))

0 comments on commit 39b9d62

Please sign in to comment.