Add maxlaw PC spider and shared proxy limiter
This commit is contained in:
@@ -26,6 +26,7 @@ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
from Db import Db
|
||||
from config import LAWTIME_CONFIG
|
||||
from utils.rate_limiter import request_slot
|
||||
|
||||
LIST_BASE = "https://m.lawtime.cn/{pinyin}/lawyer/?page={page}"
|
||||
DETAIL_BASE = "https://m.lawtime.cn"
|
||||
@@ -123,7 +124,8 @@ class LawtimeSpider:
|
||||
def _get_with_session(self, session: requests.Session, url: str, max_retries: int = 3, is_thread: bool = False) -> Optional[str]:
|
||||
for attempt in range(max_retries):
|
||||
try:
|
||||
resp = session.get(url, timeout=15, verify=False)
|
||||
with request_slot():
|
||||
resp = session.get(url, timeout=15, verify=False)
|
||||
status_code = resp.status_code
|
||||
text = resp.text
|
||||
resp.close()
|
||||
|
||||
Reference in New Issue
Block a user