私はこのコードを実行する場合:のPython + BeautifulSoup:エンコードのエラー
for link in soup.findAll('a'):
href = link.get('href')
href = str(href)
を私が示すように、変数をエンコードしようとすると、私は最後の行
href = str(href)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 68: ordinal not in range(128)
に次のエラーを取得しています以下の下:
:for link in soup.findAll('a'):
href = link.get('href')
href = href.encode('utf-8')
href = str(href)
私は次のエラーを取得します
href = href.encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'
私はここや他の場所で複数の投稿を見てきましたが、どれも適切な解決策はありませんでした。私はかなり新しいPythonです。助けてください。
あなたはエラー – Maviles