モジュール作成
scrapy genspider [モジュール名] [サイトドメイン]
例)
scrapy genspider hoge wwww.hoge.com
モジュール実行コマンド
scrapy crawl [モジュール名]
例)
scrapy crawl hoge
実行結果の出力ファイル指定
scrapy crawl hoge -o /home/fuga.csv
デバッグコマンド
scrapy shell [対象URL]
例)
scrapy shell 'https://www.hoge.com/'
インタラクティブモードになる
以下を入力していく
>>>
import re
import mojimoji
from bs4 import BeautifulSoup
from urllib.request import urlopen
soup = BeautifulSoup(response.body, "html5lib")
soup
↑ 取得結果が表示される
この後、DOMの取得コマンドを実行し、結果を確認していく
文字化け時の対策
html_data = urlopen('https://hoge.com/fuga/').read()
html_data = html_data.decode('utf-8')
soup = BeautifulSoup(html_data, "html5lib")