Skip to content

Instantly share code, notes, and snippets.

@slor
Forked from garrypolley/ch.html
Created April 22, 2013 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slor/5439031 to your computer and use it in GitHub Desktop.
Save slor/5439031 to your computer and use it in GitHub Desktop.
payload = {'html': ' <!doctype html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Home | Linkminded</title> <meta name="description" content="Discover like minded individuals with complementing skillset to collaborate on an idea together."> <meta name="keywords" content="link, minded, like, developers, designers, entrepreneurs, startup, collaborate, collaboration, find, discover, ideas, projects"> <meta name="author" content="link-minded.com"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="https://d1ttgy8gd6pa2l.cloudfront.net/img/favicon.fbe95e4d6cf2.ico"> <link rel="apple-touch-icon" href="https://d1ttgy8gd6pa2l.cloudfront.net/img/apple-touch-icon-57x57.f49a36fd4b95.png"> <link rel="apple-touch-icon-precomposed" href="https://d1ttgy8gd6pa2l.cloudfront.net/img/apple-touch-icon-57x57.f49a36fd4b95.png"> <link rel="apple-touch-icon" sizes="57x57" href="https://d1ttgy8gd6pa2l.cloudfront.net/img/apple-touch-icon-57x57.f49a36fd4b95.png"> <link rel="apple-touch-icon" sizes="72x72" href="https://d1ttgy8gd6pa2l.cloudfront.net/img/apple-touch-icon-72x72.4f666fcbd4e1.png"> <link rel="apple-touch-icon" sizes="114x114" href="https://d1ttgy8gd6pa2l.cloudfront.net/img/apple-touch-icon-114x114.442f314356da.png"> <link href="https://d1ttgy8gd6pa2l.cloudfront.net/css/s.5990c9150f54.css" rel="stylesheet" type="text/css" media="screen,projection" /> <link href=\'http://fonts.googleapis.com/css?family=Bitter\' rel=\'stylesheet\' type=\'text/css\'> <script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script></head> <body class="homepage"> <header> <div class="global-nav-contianer"> <div class="global-nav unauth"> <h1><a href="/" title="Link Minded" class="logo"><img src="https://d1ttgy8gd6pa2l.cloudfront.net/img/logo.b434696fe5c2.png" title="LinkMinded" alt="LinkMinded"></a></h1> <ul class="nav"> <li><a href="/ideas" title="Browse ideas and people to collaborate with" class="single">Browse</a></li> <li class="nav-sep">|</li> <li><a href="/resources" title="Some helpful resources for entrepreneurs" class="single">Resources</a></li> <li class="nav-sep">|</li> <li><a href="http://linkminded.tumblr.com" title="Our Blog" target=_blank class="single">Blog</a></li> <li class="nav-sep">|</li> <li><a href="/landing" title="Sign In" class="single nav-action-item open-sign-in">Sign In</a></li> </ul> </div> </div> </header> <section role="main" class="main "> <div class="messages container"> </div> <div class="section"> <div class="content top"> <h1>A location-based, online community for designer and developer entrepreneurs.</h1> <div class="left"> <img src="https://d1ttgy8gd6pa2l.cloudfront.net/img/small-puzzle-pattern.211f5a9c19a4.png" alt="Community with Ideas" /> </div> <div class="right"> <div class="request-account"> <h3>JOIN US</h3> <p>Together, designers and developers are unstoppable and the possibilities are endless. We want to help one find the other and then sit back and marvel at what they create.</p> <a href="/invites/request" class="btn request-btn">REQUEST INVITE</a> </div> </div> </div> </div> <div class="section alt"> <div class="content"> <div class="left text"> <h2>Quality</h2> <p>Not just anyone can get in and that\'s the way it should be. In order for a community like this to work, the talent has to be top-notch. If the talent is top-notch, then anything born from the partnerships will be too.</p> </div> <div class="right"> <img src="https://d1ttgy8gd6pa2l.cloudfront.net/img/community-art.e3ec33eb7723.png" alt="Quality Community" /> </div> </div> </div> <div class="section"> <div class="content"> <div class="left"> <img src="https://d1ttgy8gd6pa2l.cloudfront.net/img/location-art.76a63e0c4437.png" alt="Location Based Community" /> </div> <div class="right text"> <h2>Location-based</h2> <p>Who knows, your next door neighbor could be the collaborator you\'ve been looking to find. We want to help you find collaborators nearby. However, our entire community is available.</p> </div> </div> </div> <div class="section alt"> <div class="content"> <div class="left text"> <h2>Resources</h2> <p>Finding a team is only the first challenge. There is a lot more involved in creating, managing, and marketing something new. We provide you with a list of services and products that will help you reach the finish line.</p> </div> <div class="right"> <img src="https://d1ttgy8gd6pa2l.cloudfront.net/img/resource-art.972363f1e541.png" alt="Community Resources" /> </div> </div> </div> </section> <footer class=""> <section class="dev-des-dev-footer"> <img src="https://d1ttgy8gd6pa2l.cloudfront.net/img/des-dev-des-footer.20a1be11495b.png" alt="Designer <3 Devloper <3 Designer"/> <section> <section class="nav"> <ul> <li><a href="/">Copyright 2012 Linkminded</a></li> <li><a href="http://siliconprairiebuilt.com" title="Silicon Prairie Built"><img src="https://d1ttgy8gd6pa2l.cloudfront.net/img/silicon-prairie-built.237c6a3821e1.png" alt="Silicon Prairie Built logo"></a></li> <li class="nav-sep">|</li> <li><a href="http://blog.linkminded.co" target="_blank">Blog</a></li> <li class="nav-sep">|</li> <li><a href="mailto:feedback@linkminded.co">Send Feedback!</a></li> <li class="nav-sep">|</li> <li><a href="/terms">Terms of Use</a></li> <li class="nav-sep">|</li> <li><a href="/privacy">Privacy Policy</a></li> </ul> </section> </footer> <section class="no-mobile-yet"> <div class="no-mobile-yet-header"> <img src="https://d1ttgy8gd6pa2l.cloudfront.net/img/logo.b434696fe5c2.png" title="Linkminded" alt="Linkminded"> </div> <div class="no-mobile-yet-body"> <p class="no-mobile-yet-linkminded-describe">Linkminded is a location-based online community for designer and developer entrepreneurs.</p> <p>Unfortunately, the mobile version of our site is not quite ready. Please visit Linkminded on your desktop for the best experience.</p> <p><a href="mailto:?subject=Check%20out%20Linkminded.co!">Send an email to yourself</a> so you dont forget :)</p> <p>Thanks for understanding,<p> <p class="no-mobile-yet-team">The LinkMinded team</p> </div> </section> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script>window.jQuery || document.write(\'<script src="https://d1ttgy8gd6pa2l.cloudfront.net/js/libs/jquery-1.8.3.min.e1288116312e.js"><\\/script>\')</script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script> <script defer src="https://d1ttgy8gd6pa2l.cloudfront.net/js/libs/jquery.placeholder.min.fee1ee6e9b0f.js"></script> <script defer src="https://d1ttgy8gd6pa2l.cloudfront.net/bootstrap-2.1.1/js/bootstrap.min.41e29a3120a3.js"></script> <script type="text/javascript"> // Force our namespace to exist var lm = {geo:{}, browse:{}}; </script> <script defer src="/jsi18n/" type="text/javascript"></script> <script type="text/javascript" src="https://d1ttgy8gd6pa2l.cloudfront.net/js/s.9e098f87565f.js" charset="utf-8"></script> <script type="text/javascript"> $(function(){ }); </script> <!-- Google Analytics --> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push([\'_setAccount\', \'UA-37611430-1\']); _gaq.push([\'_setDomainName\', \'linkminded.co\']); _gaq.push([\'_trackPageview\']); (function() { var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true; ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\'; var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <script type="text/javascript">if(!NREUMQ.f){NREUMQ.f=function(){NREUMQ.push(["load",new Date().getTime()]);var e=document.createElement("script");e.type="text/javascript";e.src=(("http:"===document.location.protocol)?"http:":"https:")+"//"+"d1ros97qkrwjf5.cloudfront.net/42/eum/rum.js";document.body.appendChild(e);if(NREUMQ.a)NREUMQ.a();};NREUMQ.a=window.onload;window.onload=NREUMQ.f;};NREUMQ.push(["nrfj","beacon-3.newrelic.com","d8d1a67db1","1317556","M1QGYhNYD0YFUUdfXgoeIkMPWhVcC1wcWlgKWglfD10EUUpEWlNGFwsxWABMFV0sXV5T",0,171,new Date().getTime(),"","","","",""]);</script></body> </html>',
'url': 'http://linkminded.co'}
import requests
r = requests.post('http://localhost:8080/', data=payload)
var SERVER_HOST = '127.0.0.1:8080',
server = require('webserver').create(),
webpage = require('webpage'),
service = server.listen(SERVER_HOST, function(request, response) {
// Setup or screenshot
var page = webpage.create(),
content = request.post.html,
url = request.post.url;
page.setContent(content, url);
content = page.renderBase64('PNG');
response.write(content);
page.close();
response.close();
});
console.log("Listening to " + SERVER_HOST + " ...");

Trying this out

  • Install phantomjs
  • run phantomjs server.js
  • open a python shell and copy paste the code in pytest.py (should probably use ipython) need:
    • requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment