Code Monkey home page Code Monkey logo

scrapy-webdriver's Introduction

scrapy-webdriver

Scrape using Selenium webdriver.

Not well tested. Has probably lots of bugs, unhandled situations, and scrapy integration problems. Use at your own risk.

That being said, it works for me, in all its non-blocking glory.

Installation

For now it's not on pypi, but this should work:

pip install https://github.com/sosign/scrapy-webdriver/archive/master.zip

Or something like this, in setup.py:

setup(
    install_requires=[
        'scrapy_webdriver',
        ...,
    ],
    dependency_links=[
        'https://github.com/sosign/scrapy-webdriver/archive/master.zip#egg=scrapy_webdriver',
    ],
    ...,
    )

Configuration

Add something like this in your scrapy project settings:

DOWNLOAD_HANDLERS = {
    'http': 'scrapy_webdriver.download.WebdriverDownloadHandler',
    'https': 'scrapy_webdriver.download.WebdriverDownloadHandler',
}

SPIDER_MIDDLEWARES = {
    'scrapy_webdriver.middlewares.WebdriverSpiderMiddleware': 543,
}

WEBDRIVER_BROWSER = 'PhantomJS'  # Or any other from selenium.webdriver
                                 # or 'your_package.CustomWebdriverClass'
                                 # or an actual class instead of a string.
# Optional passing of parameters to the webdriver
WEBDRIVER_OPTIONS = {
    'service_args': ['--debug=true', '--load-images=false', '--webdriver-loglevel=debug']
}

Usage

In order to have webdriver handle your downloads, use the provided class scrapy_webdriver.http.WebdriverRequest in place of the stock scrapy Request, like so:

from scrapy_webdriver.http import WebdriverRequest
yield WebdriverRequest('http://www.example.com')

Parameters not supported (yet?) are: method, body, headers, cookies.

Hacking

Pull requests much welcome. Just make sure the tests still pass, and add to them as necessary:

python setup.py test

scrapy-webdriver's People

Contributors

ncadou avatar samos123 avatar titanjer avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.