0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

正規表現によるスクレイピング

Posted at

#正規表現によるスクレイピング
「Python クローリング&スクレイピング」という本を読んでいて詰まってしまい解決した時の方法を載せます。

p49 リスト2.11
このまま打ち込むと
①UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 130: illegal multibyte sequence
①を解決しても
②AttributeError: 'NoneType' object has no attribute 'group'
というエラーが帰ってきてしまう。

  • ①の解決方法
     openメソッドにencoding=utf-8を追加
  • ②の解決方法
    4つある「title =」 をtry: except: で囲みexcept:の中身はtitle = None とする。

これでURLと書籍のタイトルが取得できるはず。

参考サイト
https://codeday.me/jp/qa/20190511/794837.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?