From 5e1eca40a60d4ddf593f9f5e85009442742dcaed Mon Sep 17 00:00:00 2001 From: Clement Julia Date: Wed, 4 Jun 2025 10:27:31 +0200 Subject: [PATCH 1/4] curl-adapter trying new curl adapter + some fixes --- moddb/__init__.py | 6 ++++-- moddb/boxes.py | 23 +++++++---------------- moddb/client.py | 5 +++-- moddb/pages/fp.py | 8 +++++--- requirements.txt | 1 + tests/test_main.py | 4 +++- 6 files changed, 23 insertions(+), 24 deletions(-) diff --git a/moddb/__init__.py b/moddb/__init__.py index abf5750..0f59bbc 100644 --- a/moddb/__init__.py +++ b/moddb/__init__.py @@ -1,13 +1,15 @@ +from curl_adapter import CurlCffiAdapter import requests from .base import front_page, login, logout, parse_page, parse_results, rss, search, search_tags from .client import Client, Thread from .enums import * from .pages import * -from .utils import BASE_URL, LOGGER, Object, get_page, request, soup, SSLAdapter +from .utils import BASE_URL, LOGGER, Object, get_page, request, soup SESSION = requests.Session() -SESSION.mount("https://", SSLAdapter()) +SESSION.mount("http://", CurlCffiAdapter()) +SESSION.mount("https://", CurlCffiAdapter()) __version__ = "0.13.0" diff --git a/moddb/boxes.py b/moddb/boxes.py index ce005f3..8b49c40 100644 --- a/moddb/boxes.py +++ b/moddb/boxes.py @@ -208,19 +208,8 @@ def __init__(self, html: BeautifulSoup): "div", class_="table tablemenu" ) self.contact = join(html.find("h5", string="Contact").parent.span.a["href"]) - self.follow = join( - profile_raw.find_all( - "h5", - string=[ - "Mod watch", - "Game watch", - "Group watch", - "Engine watch", - "Hardware watch", - "Software watch", - ], - )[0].parent.span.a["href"] - ) + + self.follow = join(html.find("a", title="Follow")["href"]) try: share = profile_raw.find("h5", string="Share").parent.span.find_all("a") @@ -874,8 +863,8 @@ def __init__(self, html: BeautifulSoup): ) try: - self.follow = join(profile_raw.find("h5", string="Member watch").parent.span.a["href"]) - except AttributeError: + self.follow = join(html.find("a", title="Follow")["href"]) + except TypeError: LOGGER.info( "Can't watch yourself, narcissist...", exc_info=LOGGER.level >= logging.DEBUG ) @@ -1073,7 +1062,9 @@ def __init__(self, **kwargs): def __repr__(self): return f"