--- /dev/null
+"""Robot based on httpx
+
+This file is a part of Bookmarks database and Internet robot.
+
+"""
+
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__copyright__ = "Copyright (C) 2025 PhiloSoft Design"
+__license__ = "GNU GPL"
+
+__all__ = ['robot_httpx']
+
+
+import httpx
+import socksio
+
+from Robots.base import robot_base
+from Robots.util import get_ftp
+
+
+class robot_httpx(robot_base):
+ def version_str(self):
+ return 'python-httpx/%s' % httpx.__version__
+
+ async def get(self, url, req_headers, use_proxy=False):
+ if url.startswith('ftp://'):
+ error, welcome, body = get_ftp(url, self.timeout)
+ if error is not None:
+ return error, None, None, None
+ self.welcome = welcome
+ return None, None, None, body
+
+ if use_proxy:
+ proxy = self.proxy
+ else:
+ proxy = None
+
+ error = r = None
+ try:
+ r = httpx.get(url, headers=req_headers,
+ timeout=httpx.Timeout(self.timeout),
+ follow_redirects=False, proxy=proxy,
+ verify=False)
+ except (httpx.RequestError, socksio.ProtocolError) as e:
+ error = str(e)
+ return error, None, None, None
+
+ return None, r.status_code, r.headers, r.content
+
+ def get_ftp_welcome(self):
+ welcome = self.welcome
+ self.welcome = ''
+ return welcome
--- /dev/null
+"""Robot based on httpx and concurrent.futures,
+processes multiple URLs in parallel (multiprocess).
+
+This file is a part of Bookmarks database and Internet robot.
+
+"""
+
+__author__ = "Oleg Broytman <phd@phdru.name>"
+__copyright__ = "Copyright (C) 2025 PhiloSoft Design"
+__license__ = "GNU GPL"
+
+__all__ = ['robot_multihttpx']
+
+
+from Robots.concurrent_futures import cf_multiprocess
+
+
+class robot_multihttpx(cf_multiprocess):
+ robot_name = 'httpx'
. bkmk_db-venv/bin/activate &&
pip install --compile --upgrade setuptools \
beautifulsoup4 lxml m_lib.full \
- "requests[socks]" \
+ "requests[socks]" "httpx[socks]" \
aiohttp aiohttp-socks "aioftp[socks]"
}
fi
-https://pypi.org/project/httpx/
-
https://pypi.org/project/curl-cffi/
https://pypi.org/project/fake-useragent/
"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 1997-2024 PhiloSoft Design"
+__copyright__ = "Copyright (C) 1997-2025 PhiloSoft Design"
__license__ = "GNU GPL"
__all__ = ['import_robot', 'robot']
from bkmk_objects import parse_params, set_params
robot_names, robot_params = parse_params(
- environ.get("BKMK_ROBOT", "multirequests,aio"))
+ environ.get("BKMK_ROBOT", "multirequests,multihttpx,aio"))
def import_robot(robot_name):
extras_require={
'html': ['beautifulsoup4', 'lxml'],
'requests': ['requests[socks]'],
+ 'httpx': ['httpx[socks]'],
'aiohttp': ['aiohttp>=3', 'aiohttp-socks', 'aioftp[socks]'],
},
)