Skip to content

Instantly share code, notes, and snippets.

@pshapiro
pshapiro / CausalImpact.ipynb
Last active March 4, 2024 14:15
CausalImpact implementation in Python to demonstrate SEO A/B Testing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshapiro
pshapiro / GoogleEntities.ipynb
Last active October 7, 2024 09:23
Extract Entities from Search Results using Google NLP for Keyword Research Opportunities
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pshapiro
pshapiro / hitwise-audienceview-keyword-research.py
Created June 20, 2019 19:44
Automate Keyword Profiling with AudienceView - Requires and existing Crosstab Report
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
import time
import pandas as pd
import os
//Extract Google Trends topics
//Usage: copy and paste in Chrome Javascript console with trending pages open. for example:
//https://trends.google.com/trends/trendingsearches/realtime?geo=US&category=all
function getTopics(){
topics_anchors = document.querySelectorAll("div.details-wrapper > div.details > div.details-bottom > div.subtitles-text-wrapper.visible > div.summary-text > a");
var topics = [];
for (topic of topics_anchors){
@pshapiro
pshapiro / metadesc.py
Created June 6, 2018 22:19
Use Text Summarization Algorithms to Help Aid the Writing of Meta Descriptions
import csv
import os
from sumy.parsers.html import HtmlParser
from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer
from sumy.summarizers.lsa import LsaSummarizer as Lsa
from sumy.summarizers.luhn import LuhnSummarizer as Luhn
from sumy.summarizers.text_rank import TextRankSummarizer as TxtRank
from sumy.summarizers.lex_rank import LexRankSummarizer as LexRank
from sumy.summarizers.sum_basic import SumBasicSummarizer as SumBasic
@revox
revox / youtube_scraper.py
Last active May 30, 2021 06:24
Basic scrape and write to CSV example using BS4
# basic scrape and write demonstration used in Goldsmiths digital sandbox 2014
import urllib # fetches raw web pages for us
import bs4 # turns raw web pages into object hierarchy and provides selectors (like CSS and Xpath does)
import csv # simplifies the process of writing data to Comma Separated Values in a file
# a list of URLs on YouTube that we want to scrape data from
pagesToScrape = ['http://www.youtube.com/watch?v=9hIQjrMHTv4'
,'https://www.youtube.com/watch?v=Uk8x3V-sUgU']
# open a file in append mode to write into in the same directory where we ran this script from