LoginSignup
18
18

More than 5 years have passed since last update.

1分でPython&CSSセレクタによるスクレイピングを実現する

Last updated at Posted at 2013-09-27

導入

導入
pip install pyquery

サンプルコード

サンプルコード
# -*- coding: utf-8 -*-
from pyquery import PyQuery as pq
url = "http://www.sicafe.net/macPackageManageTips/html/homebrewPythonInstall.html"
query = pq(url)
for a in query.find("a"):#CSSセレクタ!!
  print pq(a).text()


#出力結果
#前略
#Mac OS X Lion / homebrew にて python の環境を整える
#ポイント
#手順
#1. brew の更新と python のインストール
#2. pipの再インストール
#3. 古い環境の掃除と path の変更
#4. sphinx とかを再インストールしてみる
#5. pip で PIL をインストールしようとしても失敗する
#6. pip で PIL をインストールするときの注意点
#とりあえず現状の pip freeze
#Mac OS X Lion でとりあえずやった環境設定
#Show Source
#index
#previous
#JAWSUG-Okinawa 2nd study NOTE
#Sphinx
18
18
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
18
18