Selenium versus BeautifulSoup for web scraping

I’m scraping content from a website using Python. First I used BeautifulSoup and Mechanize on Python but I saw that the website had a button that created content via JavaScript so I decided to use Selenium. Given that I can find elements and get their content using Selenium with methods like driver.find_element_by_xpath, what reason is […]

Minutes since midnight in Momentjs

In pure JS, this would be how. How can I find out the number of minutes since midnight for a given moment object (without extracting to Date)? Must take into account DSTs Minutes should be rounded Must work with local time (not convert to UTC)

How do I negate the parameter for AngularJS ng-if directive?

Quick Example: There is a routed parameter (/Home/:isLoggedIn) that equates to true or false. (/Demo/#/Home/false) and a controller property this.loggedIn = this.routeParams.loggedIn; I have a view (Home.html) that has two elements, each with an ng-if attribute. <div ng-if=”home.loggedIn”> Logged In! </div> <div ng-if=”!home.loggedIn”> Not Logged In… </div> If I navigate to /Demo/#/Home/true then the first […]

Changing axis min/max on an existing plot using Flot JQuery Library

I’ve created a series of plots using the flot library, which are all displayed on a single page. Is there a way to update the X axis min and max options (options.xaxis.min, options.axis.max) values WITHOUT re-plotting the plots ($.plot(‘placeholder’,data,options))? I found this solution: http://osdir.com/ml/flot-graphs/2012-02/msg00064.html Which suggests that the following line would do it, but it […]

Select a row from html table and send values onclick of a button

I have HTML table where I need to select a row and send its first cell ID to a button and onclick of the button send the selected value to a function in Javascript. How can I achieve this? test.html : <table id=”table”> <tr> <td>1 Ferrari F138</td> <td>1 000€</td> <td>1 200€</td> </tr> <tr> <td>2 Ferrari […]

Backbone.js fetch problem (can't refresh data immediately)

I have such code: var MyModel = Backbone.Model.extend(); var MyCollection = Backbone.Collection.extend({ url: ‘/url/’, model: MyModel }); var coll = new MyCollection(); The url is correct and returns correct json. But if I try to use the next code: $(‘#fetch’).click(function(){ coll.fetch(); console.log(coll.toJSON()); }); it shows me data only after the second click (http-response in firebug […]

How [1,2] + [4,5,6][1] = 1,25 in JavaScript

This question already has an answer here: Why is [1,2] + [3,4] = “1,23,4” in JavaScript? 13 answers

jQuery fadeIn on position:absolute causes z-index issue

Technically I’m using fadeToggle() but they’re cousins… basically my issue is that I have an absolutely positioned div which I am using slideToggle() on but the Z-index is not being set until the animation completes. The result is that during the fade the text in a neighboring div (which has a lower z-index value than […]

How do I get the reference to an existing YouTube player?

<iframe width=”560″ height=”315″ src=”//www.youtube.com/embed/M7lc1UVf-VE” frameborder=”0″ allowfullscreen></iframe> I have a few questions on what happens when I embed a YouTube video using source code like above. The code should generate a YouTube Player object that processes the video the way users like. When I generate a Youtube Player by myself using Youtube Player API(instead of using […]

adding multiple event listeners to one element

So my dilemma is that I don’t want to write the same code twice. Once for the click event and another for the touchstart event. Here is the original code: document.getElementById(‘first’).addEventListener(‘touchstart’, function(event) { do_something(); }); document.getElementById(‘first’).addEventListener(‘click’, function(event) { do_something(); }); How can I compact this? There HAS to be a simpler way!