headless internet browser? [closed]

2018-12-31 21:25发布

I would like to do the following. Log into a website, click a couple of specific links, then click a download link. I'd like to run this as either a scheduled task on windows or cron job on Linux. I'm not picky about the language I use, but I'd like this to run with out putting a browser window up on the screen if possible.

14条回答
高级女魔头
2楼-- · 2018-12-31 22:03

PhantomJS is a headless WebKit-based browser that you can script with JavaScript.

查看更多
有味是清欢
3楼-- · 2018-12-31 22:07

Have a look at PhantomJS, a JavaScript based automation framework available for Windows, Mac OS X, Linux, other *ix systems.

Using PhantomJS, you can do things like this:

console.log('Loading a web page');

var page = new WebPage();
var url = "http://www.phantomjs.org/";

page.open(url, function (status) {
    // perform your task once the page is ready ...
    phantom.exit();
});

Or evaluate a page's title:

var page = require('webpage').create();
page.open(url, function (status) {
    var title = page.evaluate(function () {
        return document.title;
    });
    console.log('Page title is ' + title);
});

Examples from PhantomJS' Quickstart page. You can even render a page to a PNG, JPEG or PDF using the render() method.

查看更多
登录 后发表回答