forked from clemfromspace/scrapy-selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhttp.py
32 lines (24 loc) · 1.04 KB
/
http.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""This module contains the ``SeleniumRequest`` class"""
from scrapy import Request
class SeleniumRequest(Request):
"""Scrapy ``Request`` subclass providing additional arguments"""
def __init__(self, wait_time=None, wait_until=None, screenshot=False, script=None, *args, **kwargs):
"""Initialize a new selenium request
Parameters
----------
wait_time: int
The number of seconds to wait.
wait_until: method
One of the "selenium.webdriver.support.expected_conditions". The response
will be returned until the given condition is fulfilled.
screenshot: bool
If True, a screenshot of the page will be taken and the data of the screenshot
will be returned in the response "meta" attribute.
script: str
JavaScript code to execute.
"""
self.wait_time = wait_time
self.wait_until = wait_until
self.screenshot = screenshot
self.script = script
super().__init__(*args, **kwargs)