Accept JSON parsing errors in JSON-LD extractor
評価
調査の方向性
Start at JsonLdExtractor._extract_items(self, node), where json.loads parses the node contents. Check how malformed JSON-LD is handled without affecting microdata or RDFa extraction; done means invalid JSON-LD yields no items while other embedded metadata remains available.
索引モデルが issue の本文から書いたものです。
説明
When the JsonLdExtractor tries to parse json ld in some web page raise ValueError; no json object could be decoded.
My solution was to catch the error in JsonLdExtractor._extract_items(self, node) (because maybe the extractor detected some microdata or rdfa in the webpage but the error only occurs with json-ld, and if we catch the error in extruct.extract we'll lose that data) and by default return an empty list:
def _extract_items(self, node):
try:
data = json.loads(node.xpath('string()'))
if isinstance(data, list):
return data
elif isinstance(data, dict):
return [data]
except Exception as e:
print e
return []
- 主要言語
- Python
- スター
- 986
- フォーク
- 127
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
scrapinghub/extruct のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
scrapinghub/extruct#278 · リアクション 1 件 ·
-
Migrate to pytest対応中かも @Rotzbua が 135 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
scrapinghub/extruct#252 ·
-
Tests fail with windows対応中かも @Rotzbua が 136 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
scrapinghub/extruct#251 ·
-
Install on modern pip and setuptools is failing対応中かも @Rotzbua が 163 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
scrapinghub/extruct#241 · コメント 5 件 ·
-
Fix the Build Status badge対応中かも @Rotzbua が 163 日前に担当しました。 オープンbug docs
難易度 1/5 1時間未満 初心者へのやさしさ 56/100
scrapinghub/extruct#236 ·
scrapinghub/extruct の issue をすべて見る
似ている issue
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount due対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 79/100
developmentseed/titiler-covjson#164 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
awslabs/visual-asset-management-system#2164 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
MakazhanAlpamys/Soup#3589 ·
メンテナーはふだん 1 日以内に返信
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocketオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信