Firefox is my go-to browser for any automation tasks at first, because...it's like that, and that's the way it is. Obviously Chrome is a great browser too, and chromedriver is one of the most useful automation tools out there. One area where Chrome falls down however is that it will only screenshot the available viewport. Here's a workaround. NB This script requires PIL (Python Imaging Library). I
次のようにページ全体のサイズがブラウザーの縦横ともに大きいと想定します。 この時、scroll_width, scroll_height, row_count, col_count = 0に初期化します。 ページの右端に当たるまでスクリーンショットを撮って画面の横幅の分スクロールするのを繰り返していきます。 横にスクロールする度にcol_countを増やします。 必須うではないですがtmp_imageのファイル名はtmp_{row_count}_{col_count}.pngとかにすると後でファイルだけ見た時にわかりやすいです。 tmp_imageをstitched_imageにscroll_widthとscroll_heightの位置に貼り付けます。 スクロールサイズがページの残りサイズを超えたら残りの分だけ切り出してtmp_imageに保存しstitched_imageに貼り付けます。
Selenium便利なんだけど、ブラウザ立ちあげないといけないのはサーバーで使いにくくて不便だよなと思っていたのだけどPhantomJS使えることを知ったので早速遊んでた。なにやりたいかというとGoogle Patent Searchから特許ID抜き出したいのだけど、Python+Selenium+PhantomJSの組み合わせでできることがわかった。 from selenium import webdriver import time driver = webdriver.PhantomJS() driver.get("https://www.google.co.jp/webhp?hl=ja&tab=ww&authuser=0#authuser=0&hl=ja&q=python") print driver.current_url time.sleep(2) driver.save_sc
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く