Skip to content

Instantly share code, notes, and snippets.

BACKGROUND

We want to benchmark our LinkedIn Company Page against a series of our competitors. As part of this, we want to collect data on their posts, and the engagement on their posts.

From a list of LinkedIn Company Pages -- e.g. (link removed):

Collect posts and their metadata (date published, social actions on the post, the user IDs of people who has engaged with the post etc. -- a full list is published below)

We expect to collect at least 100 posts per page. Note that LinkedIn pages have an “infinite scroll” feature.

@mediaczar
mediaczar / python_install.md
Created October 15, 2019 14:42
Installing python on fresh Mac

Set up for Python

Consider installing iTerm2

There’s nothing wrong with the Terminal, but iTerm2 https://www.iterm2.com/

Install command line developer tools

xcode-select --install

Install separate version of python

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

# Terms of Service
# Privacy Policy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import fbtools as fb
import json
fb.token_string = fb.get_token()
args = fb.get_args()
#!/usr/bin/env/ python
import requests
from bs4 import BeautifulSoup
def collect(year):
url = "https://www.interbrand.com/best-brands/best-global-brands/%s/ranking" % str(year)
html = requests.get(url)
page = BeautifulSoup(html.text, features="html5lib")
return page
@mediaczar
mediaczar / sitemap_share_counter.py
Created December 5, 2013 16:39
The ScraperWiki harvester uses a site's sitemap.xml to generate a list of URLs, then queries each URL against APIs from Facebook, Twitter and Pinterest to find how often each page has been shared.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###################
import scraperwiki
import requests
import xmltodict
import json
import time
@mediaczar
mediaczar / sitemap-to-link_stat.py
Created November 28, 2013 14:56
Using the Daily Mail's sitemap.xml as the basis to query Facebook's `link_stat` FQL table
@mediaczar
mediaczar / Next iteration
Created September 18, 2013 09:27
I'm confused by a bit of Python iteration; it looks extremely terse & useful, but I can't see what's happening.
#!/usr/bin/env python
from instagram.client import InstagramAPI
access_token = '[this space intentionally left blank]'
api = InstagramAPI(access_token=access_token)
recent_media, next = api.user_recent_media() # What's happening here? I don't understand syntax
@mediaczar
mediaczar / countbigram.pl
Last active December 10, 2015 17:48
Count Bigrams (based on original by T. J. Otlogetswe)
#!/usr/bin/perl
# bigramcount - counts the number of bigrams in a text,
# prints them out in order of decreasing frequency.
# author: Thapelo J. Otlogetswe
# date: 2006-01-27
# http://thaps.blogspot.co.uk/2006/01/perl-bigram-count.html
# modified: Mat Morrison (@mediaczar)
# date: 2013-01-06