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

オープン 初心者向け
#161 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@Th-Shivam がすでに取り組んでいます。

2026年10月1日 から。

  • #162 @Th-Shivam による — オープン

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
92/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

backend/app/modules/scraper/extractor.py の Article_extractor._fetch_html() から始めます。backend/ ディレクトリから提供された uv コマンドを実行して、現在のリクエスト動作を確認します。設定された User-Agent がヘッダーとして送信され、ヘッダーが URL のクエリパラメーターにシリアライズされなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
TypeScript
スター
58
フォーク
90
平均マージ
11時間 51分
マージ済み PR(30日)
3

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/Perspective のほかの issue

AOSSIE-Org/Perspective の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。