0
0

More than 3 years have passed since last update.

Scrapy 各種コマンド

Last updated at Posted at 2020-03-09

モジュール作成

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")
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