Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Web サイトをクロールするために、scrapy を使用しています。
with open('test.html', 'wb') as f: f.write(response.body)
このブロックを使用して、本文をファイルに書き込みます。ファイルを開くと、多くの「a」タグが表示されます。
印刷で同じものを印刷すると。「a」タグが 2 つだけ表示されます
print response.body
ここで何が起こっているか分かりますか?
私は問題を解決しました。クロールされた Web サイトには<html>、コンボボックスに 2 番目のタグがあります。
<html>
私は PyQuery を使用していましたが、html 構造のタグに問題がある場合、PyQuery は機能していません。
セレクターを xpath に変更したところ、html 内のすべての a タグが検出されるようになりました。