Is it possible to prevent img and css download in phantomjs webdriver(selenium)?
Asked
Active
Viewed 1,397 times
1
-
check this http://stackoverflow.com/questions/7157994/do-not-want-images-to-load-and-css-to-render-on-firefox – Tarek Hallak Jul 24 '13 at 09:38
-
1phantomjs driver uses webkit. – Dmitrijs Zubriks Jul 24 '13 at 09:46
-
Search for "phantomjs adblock" in Google. – PP. Jul 24 '13 at 11:19
-
You can make selenium go through a proxy, that proxy can be as simple as a small python script that you can determine whether to fetch/return a resource or block it with you custom heuristics. – Pykler Dec 19 '13 at 17:41
2 Answers
2
If you check phantomjs API, an option can be passed as: --load-images=[true|false] load all inlined images (default is true). Also accepted: [yes|no].
However, you cannot block CSS download AFAIK.

Rafael I
- 66
- 6
0
If you are using HtmlUnitDriver
on Java
, you can use following method to modify the webclient options:
@Override
protected WebClient modifyWebClient(WebClient client) {
client.getOptions().setCssEnabled(false);
return client;
}
hope this helps

Anudeep Samaiya
- 1,910
- 2
- 28
- 33