phantomjs

Scraping attempts getting 403 error

房东的猫 提交于 2019-12-18 07:23:00
问题 I am trying to scrape a website and I am getting a 403 Forbidden error no matter what I try: wget CURL (command line and PHP) Perl WWW::Mechanize PhantomJS I tried all of the above with and without proxies, changing user-agent, and adding a referrer header. I even copied the request header from my Chrome browser and tried sending with my request using PHP Curl and I am still getting a 403 Forbidden error. Any input or suggestions on what is triggering the website to block the request and how

Trying to run PhantomJS on OpenShift: cannot patch GhostDriver so that it can bind on the server IP address

纵然是瞬间 提交于 2019-12-18 07:09:36
问题 tl;dr How to solve version 'GLIBCXX_3.4.15' not found when I cannot be root on the Linux server? I'm tring to use PhantomJS on OpenShift. As explained in this article, PhantomJS GhostDriver binds on localhost only, while on OpenShift, you cannot bind anything on localhost (you need to specify the machine IP address). Paolo Bernardi (the author of the article) shares a patch that fixes PhantomJS, so that it's possible to bind on an IP address. The problem is that the provided patch does not

Running 'casperjs test' in phantom

倾然丶 夕夏残阳落幕 提交于 2019-12-18 07:04:52
问题 So I have a file running in node which runs a local copy of PhantomJS as below shows: phantom.casperPath = 'node_modules/casperjs'; phantom.injectJs('node_modules/casperjs/bin/bootstrap.js'); var casper = require('casper').create({ viewportSize: config.viewportSize }); casper.test.begin('Runing tests here', 5, function suite(test) { // Tests here }); Without the casper.test.begin() my tests function fine. I have the correct version 1.1.0 which can use this test suite but I get the following

How do I override window.screen?

陌路散爱 提交于 2019-12-18 07:00:09
问题 I'm writing a simple PhantomJS app that scrapes particular pages looking for patterns. In one of these pages, the owner of the site is reading the window.screen width/height properties and changing the URL on me (which is cancelling the loading of the rest of the page). Setting the viewportSize changes the width/height values of the window, but not of the screen object. Attempt 1 My first step was disabling navigation, like so: tab.onLoadStarted = function () { tab.navigationLocked = true; };

How to execute phantomjs file browser?

大兔子大兔子 提交于 2019-12-18 06:56:44
问题 I'm new to phantomJs. I've installed phantomjs in my system(Ubuntu) and executed a sample code "test.js" in terminal like, test.js: console.log("WELCOME TO PHANTOMJS"); phantom.exit(); In terminal phantomjs test.js its executed fine shows expected output. NOw my question is, Is there any possibilites to execute above js file in a browser by importing that js file in a html file like, <script src="test.js".....></script> If is it possible means how to do?? Please help me. 回答1: Short Version

Crop screenshot to element in PhantomJS

心已入冬 提交于 2019-12-18 05:20:46
问题 I know it's possible to arbitrarily crop a screenshot in PhantomJS, using page.clipRect() : page.clipRect = { top: element_top, left: element_left, width: element_width, height: element_height }; So, I am trying to grab the positioning and width/height of a specific element using jQuery. However, my code below (based on the last section of the PhantomJS rasterize.js example) isn't working; it just keeps the default values. I'm thinking I must have done something wrong with respect to variable

Automate daily csv file download from website button click

非 Y 不嫁゛ 提交于 2019-12-18 05:14:15
问题 I would like to automate the process of visiting a website, clicking a button, and saving the file. The only way to download the file on this site is to click a button. You can't navigate to the file using a url. I have been trying to use phantomjs and casperjs to automate this process, but haven't had any success. I recently tried to use brandon's solution here Grab the resource contents in CasperJS or PhantomJS Here is my code for that var fs = require('fs'); var cache = require('./cache');

How do I generate a png file w/ selenium/phantomjs from a string?

怎甘沉沦 提交于 2019-12-18 04:55:12
问题 I am using selenium/phantomjs to create png files of html in python. Is there a way to generate the png from an html string or filehandle (instead of a website)? I've searched through the selenium docs and googled but couldn't find an answer. I have: htmlString = '<html><body><div style="background-color:red;height:500px;width:500px;">This is a png</div></body></html>' myFile = 'tmp.html' f = open(myFile,'w') f.write(htmlString) from selenium import webdriver driver = webdriver.PhantomJS()

Can't find variable - PhantomJS

守給你的承諾、 提交于 2019-12-18 04:43:12
问题 I post here after many hours of fruitless searching. PhantomJS does not allow me to use a variable as in the code below, with the error message when running my script "Can not find variable". Do you have any idea where can be my problem? page.open(myurl, function (status) { if (status == 'success') { page.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js", function() { elem = page.evaluate(function () { /* Select one element with jQuery */ myElem = $('body'); return

Installing PhantomJS on server

落爺英雄遲暮 提交于 2019-12-18 03:48:56
问题 I'm using PhantomJS on windows and accessing the files through command line. Now I want to install it on the server I'm working on local host so I want it to be installed on Apache, so that I may integrate Phantom with my html and PHP to be used within a web page. I'm using Windows 8.1 and Apache Server for localhost. Can I actually do that? How to use it in web services now? How i will use it if I have to make my web online? should I have t ask my hosting provider to place this thing on