[BUG]: Scraper passes headers as query params in requests.get (User-Agent never sent)

Đang mở Phù hợp với người mới
#161 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

@Th-Shivam đang làm issue này rồi.

Từ ngày 1/10/2026.

  • #162 của @Th-Shivam — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
92/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu trong backend/app/modules/scraper/extractor.py tại Article_extractor._fetch_html(). Chạy lệnh uv được cung cấp từ thư mục backend/ để quan sát hành vi yêu cầu hiện tại. Công việc được hoàn tất khi User-Agent đã cấu hình được gửi dưới dạng header và các header không còn được tuần tự hóa vào các tham số truy vấn URL.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug
Bug Description

In backend/app/modules/scraper/extractor.py, Article_extractor._fetch_html() calls:

res = requests.get(self.url, self.headers, timeout=10)

The second positional argument of requests.get(url, params=None, **kwargs) is params, not headers. So:

  1. The custom User-Agent header is never sent.
  2. The headers dict is instead serialized into the URL query string (e.g. ?User-Agent=Mozilla%2F5.0...), producing a malformed request.

_fetch_html() backs extract_with_bs4(), which is the last-resort fallback (it runs only when Trafilatura and Newspaper3k both fail) — so exactly when robust fetching matters most, the request goes out without the intended User-Agent and with a polluted URL.

Steps to Reproduce

Deterministic, no app/keys needed — from the backend/ directory:

uv run python -c "from app.modules.scraper.extractor import Article_extractor; print(Article_extractor('https://httpbin.org/get')._fetch_html())"

Observe the response: the args object contains User-Agent (proving it was sent as a query param), and headers.User-Agent is the default python-requests/... (proving the custom UA was not applied).

Logs and Screenshots

Deterministic, no app/keys needed — from the backend/ directory:

uv run python -c "from app.modules.scraper.extractor import Article_extractor; print(Article_extractor('https://httpbin.org/get')._fetch_html())"

Observe the response: the args object contains User-Agent (proving it was sent as a query param), and headers.User-Agent is the default python-requests/... (proving the custom UA was not applied).

Environment Details
  • Present on current main (commit 70a2af4), independent of OS.
  • Backend: Python 3.13, requests>=2.32.3.
  • Root cause is a universal requests API behavior, so it reproduces in every environment.
Impact

Medium - Feature works but has issues

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Ngôn ngữ chính
TypeScript
Star
58
Fork
90
Merge trung bình
11 giờ 51 phút
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AOSSIE-Org/Perspective

Tất cả issue của AOSSIE-Org/Perspective

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.