问题
Reworded completely:
My vision: Web interface that takes email, student ID, password and desired class as parameters for heroku script. And then once a spot is open, use a webdriver on heroku to register them (using university student portal) and then email them the result (success: you got in, failure: spot was no longer open, will keep trying).
Here's the thing: I have made this on my computer locally and it works like a charm. I used selenium and chromedriver and had a grand old time.
But: How can I get this on heroku? My options seem to be: selenium with ghostdriver, casperjs, phantomjs, Requests (HTTP for HUmans). Screenshots would be nice for debugging but absolutely necessary.
"Best according to what criteria": Scalability, lightweight, easy to build fast (registration is two weeks from October 27 (today) )
回答1:
If you're needing to use Javascript in your application or just find it easier to script a browser than using requests
or urllib2
, a headless browser is a good way to go. I'd personally recommend phantomjs
as it's quite easy to use in node, js, or python.
You'll need a custom buildpack, which is fairly easy to install, here's a good one. Note, this requires the cedar stack.
Here's a bit of info on adding a buildpack.
And here's example setup code from the README of the buildpack repo:
$ heroku create --stack cedar-14 --buildpack https://github.com/ddollar/heroku-buildpack-multi
$ echo "https://github.com/ddollar/heroku-buildpack-apt" >> .buildpacks
$ echo "https://github.com/srbartlett/heroku-buildpack-phantomjs-2.0.git" >> .buildpacks
$ cat <<EOT >> Aptfile
libicu52
libjpeg8
libfontconfig
libwebp5
EOT
$ git push heroku master
Hope that helps!
来源:https://stackoverflow.com/questions/33351653/whats-the-best-way-to-drive-a-browser-headlessly-on-heroku-for-my-purposes