Using the Network Inspector, jQuery, querySelector, and async/await to get structured data out of messy websites

When you’re trying to analyze political data — whether you’re trying to build a list of voters in your district or track electoral trends — you’ll often have to grab government data off the internet.

The trouble is that government websites rarely let you download an Excel sheet or CSV of all the underlying data. More often, you’ll have to turn to the time-honored technique of scraping structured data off a clunky website.

If you want to get good at capturing and analyzing government data, you’ll have to add many scraping tools to your toolbelt, from parsing dirty PDFs to…

When it’s better to use strategies that are normally worse

Image credit: Jonathan Petersson

For the final installment in this series, I’d like to turn to an especially topical subject: how campaigns strategize at the very end of election seasons.

In the last few weeks of an election, time and money are more scarce than ever, and each decision is pivotal. That’s why the end of the campaign season is the most strategically-interesting part, like how the last five minutes are the most interesting part of any pro sports game.

The current US Presidential election is in a quite interesting strategic place, so let’s use that as our jumping-off point for this piece.


How political parties can find — and exploit — breaking points in electoral systems

A hilariously-gerrymandered political district in Pennsylvania that some say looked like Goofy kicking Donald Duck. (Fortunately, the courts threw it out in 2018.) Source: WBUR

So far in this series, we’ve talked about a few essential concepts that political campaigns and politically-engaged citizens need to understand: the tradeoffs of persuasion vs. GOTV, how elasticity shapes swing states, and why undecided voters make polls a lot less reliable.

But we still haven’t addressed the elephant in the room: gerrymandering. This unfortunate reality of the American political system discourages many people considering running for office. “These sleazy politicians have predetermined the outcome of the race,” they think. “There’s no point running.”

In this post, we’ll see how gerrymanderers make trade-offs that make a lot of districts competitive…

Or, why a 4-point lead could mean one of two very different things

In the first two entries in this series on campaign strategy, we’ve seen how politicians can more efficiently use the tools in their toolkit by understanding concepts like elasticity, expected margin impact, and the persuasion-GOTV matrix. We’ve also learned how everyday citizens can become smarter consumers of political news by understanding that there are two very different kinds of swing states in America.

To continue down that path, I want to use this piece to explain how we miss a key factor when we read election polls and how that leads voters, election forecasters, pundits, and politicians to make crucial…

Or, why NC and NH are very different kinds of swing states

Welcome back to my series on the five essentials of strategy for political campaigns and the math, stats, and economics concepts behind them. My first piece was on categorizing voters and applying different vote-getting strategies to each using the persuasion-GOTV matrix.

This time, we’re going to zoom out to answer a more fundamental question: how hard will it be for my favored candidate to win? We’ll introduce a new concept, elasticity, to explain why looking at raw vote totals isn’t enough, and why so many candidates easily reach the mid-40s but can never make it to 51%. …

A scientific approach to squeezing the most votes out of your electoral district

When you’re working on a political campaign — either seeking office yourself or working for someone you believe in — you’ll always be operating in a tough environment. There are always too many votes to get, too many babies to kiss and hands to shake, but never enough money, time, or volunteers to do it all.

Your team has to learn the strategy for optimizing your scarce resources to win the race. I’m working as a data scientist on a Florida congressional race where our guy is seeking an upset win in a district tilted 13 points against him, and…

Advice from a Google Associate Product Manager*5qaGjfDpGqpw5Bq5.jpeg

“Why are manhole covers round?

Movies like “The Internship” will assure you that being able to answer questions like that — as well as hunting down fictitious professors and winning Quidditch matches — is your ticket to a job at Google.

But these brainteaser questions are more fable than fact and, well, the other things won’t help much either. So if you’re looking for a job at Google, you’ll have to take a more sensible approach. You’ll have to prepare for the actual interviews you’ll be getting.

I’m an incoming Google Associate Product Manager (APM), a two-year rotational product management…

Spearphishing, VPNs, Bitcoin, and more about how the Russians allegedly hacked Clinton and the Democrats

Special counsel Robert Mueller, who charged Russian intelligence officers with stealing and leaking documents and emails to impact the 2016 election. (Source: Wikimedia)

Yesterday Robert Mueller’s special counsel indicted 12 Russian intelligence officers for hacking into the computers of Hillary Clinton’s presidential campaign and the Democratic Party, stealing documents and emails, and leaking them to impact the 2016 election.

This “bombshell” indictment has tremendous political implications, but it involves a lot of technology terms that non-experts might not be familiar with: spearphishing, VPNs, Bitcoin, and more. It’s vitally important that Americans understand how this attack worked — so first we need to demystify the tech jargon.

In this article, I’m going to break down the tech concepts in the indictment and explain, in…

My firsthand tips to save money, stay safe, and have fun

For our last college spring break, my girlfriend and I decided to get out of the snowy Northeast and visit the famous resort town of Cancun, Mexico. While getting an all-inclusive resort and lying on the beach all day sounded relaxing, we wanted more adventure and authentic experiences (and food). Plus, we’re broke college students.

So we set off on our 9-day adventure in Cancun, doing everything from snorkeling to seeing Chichen Itza. It was a blast. But while we had an easy time deciding what to do, we were pretty clueless about how to do everything.

Resort or Airbnb…

A behind-the-scenes look at the Civic Digital Fellowship

Photo by Luca Bravo on Unsplash

I recently sat down with Marquis Cabrera, a tech entrepreneur and serial innovator who blogs for HuffPost, to chat about why Coding it Forward started the Civic Digital Fellowship and our thoughts on how we can play a role in modernizing the federal workforce.

We’re beyond excited about this feature and the opportunity to share our story with others. Check out the full article on HuffPost!

Neel Mehta

Associate Product Manager @Google. Former CS @Harvard. Author of "Swipe to Unlock: A Primer on Technology and Business Strategy". All views my own.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store