DOI: 10.34894/obvaoy
title: CompuCrawl: Full database and code

description: &lt;p&gt;&lt;br&gt;&lt;/p&gt;&lt;p dir=\"ltr\"&gt;This folder contains the full set of code and data for the CompuCrawl database. The database contains the archived websites of publicly traded North American firms listed in the Compustat database between 1996 and 2020\u2014representing 11,277 firms with 86,303 firm/year observations and 1,617,675 webpages in the final cleaned and selected set.&lt;/p&gt;&lt;p dir=\"ltr\"&gt;The files are ordered by moment of use in the work flow. For example, the first file in the list is the input file for code files 01 and 02, which create and update the two tracking files \"scrapedURLs.csv\" and \"URLs_1_deeper.csv\" and which write HTML files to its folder. \"HTML.zip\" is the resultant folder, converted to .zip for ease of sharing. Code file 03 then reads this .zip file and is therefore below it in the ordering.&lt;/p&gt;&lt;p dir=\"ltr\"&gt;The full set of files, in order of use, is as follows:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;Compustat_2021.xlsx&lt;/i&gt;: The input file containing the URLs to be scraped and their date range.&lt;/li&gt;&lt;li&gt;&lt;i&gt;01 Collect frontpages.py&lt;/i&gt;: Python script scraping the front pages of the list of URLs and generating a list of URLs one page deeper in the domains.&lt;/li&gt;&lt;li&gt;&lt;i&gt;URLs_1_deeper.csv&lt;/i&gt;: List of URLs one page deeper on the main domains.&lt;/li&gt;&lt;li&gt;&lt;i&gt;02 Collect further pages.py&lt;/i&gt;: Python script scraping the list of URLs one page deeper in the domains.&lt;/li&gt;&lt;li&gt;&lt;i&gt;scrapedURLs.csv&lt;/i&gt;: Tracking file containing all URLs that were accessed and their scraping status.&lt;/li&gt;&lt;li&gt;&lt;i&gt;HTML.zip&lt;/i&gt;: Archived version of the set of individual HTML files.&lt;/li&gt;&lt;li&gt;&lt;i&gt;03 Convert HTML to plaintext.py&lt;/i&gt;: Python script converting the individual HTML pages to plaintext.&lt;/li&gt;&lt;li&gt;&lt;i&gt;TXT_uncleaned.zip&lt;/i&gt;: Archived version of the converted yet uncleaned plaintext files.&lt;/li&gt;&lt;li&gt;&lt;i&gt;input_categorization_allpages.csv&lt;/i&gt;: Input file for classification of pages using GPT according to their HTML title and URL.&lt;/li&gt;&lt;li&gt;&lt;i&gt;04 GPT application.py&lt;/i&gt;: Python script using OpenAI\u2019s API to classify selected pages according to their HTML title and URL.&lt;/li&gt;&lt;li&gt;&lt;i&gt;categorization_applied.csv&lt;/i&gt;: Output file containing classification of selected pages.&lt;/li&gt;&lt;li&gt;&lt;i&gt;exclusion_list.xlsx&lt;/i&gt;: File containing three sheets: 'gvkeys' containing the GVKEYs of duplicate observations (that need to be excluded), 'pages' containing page IDs for pages that should be removed, and 'sentences' containing (sub-)sentences to be removed.&lt;/li&gt;&lt;li&gt;&lt;i&gt;05 Clean and select.py&lt;/i&gt;: Python script applying data selection and cleaning (including selection based on page category), with setting and decisions described at the top of the script. This script also combined individual pages into one combined observation per GVKEY/year.&lt;/li&gt;&lt;li&gt;&lt;i&gt;metadata.csv&lt;/i&gt;: Metadata containing information on all processed HTML pages, including those not selected.&lt;/li&gt;&lt;li&gt;&lt;i&gt;TXT_cleaned.zip&lt;/i&gt;: Archived version of the selected and cleaned plaintext page files. This file serves as input for the word embeddings application.&lt;/li&gt;&lt;li&gt;&lt;i&gt;TXT_combined.zip&lt;/i&gt;: Archived version of the combined plaintext files at the GVKEY/year level. This file serves as input for the data description using topic modeling.&lt;/li&gt;&lt;li&gt;&lt;i&gt;06 Topic model.R&lt;/i&gt;: R script that loads up the combined text data from the folder stored in \"TXT_combined.zip\", applies further cleaning, and estimates a 125-topic model.&lt;br&gt;&lt;i&gt;TM_125.RData:&lt;/i&gt; RData file containing the results of the 125-topic model.&lt;/li&gt;&lt;li&gt;&lt;i&gt;loadings125.csv&lt;/i&gt;: CSV file containing the loadings for all 125 topics for all GVKEY/year observations that were included in the topic model.&lt;/li&gt;&lt;li&gt;&lt;i&gt;125_topprob.xlsx&lt;/i&gt;: Overview of top-loading terms for the 125 topic model.&lt;/li&gt;&lt;li&gt;&lt;i&gt;07 Word2Vec train and align.py&lt;/i&gt;: Python script that loads the plaintext files in the \"TXT_cleaned.zip\" archive to train a series of Word2Vec models and subsequently align them in order to compare word embeddings across time periods.&lt;/li&gt;&lt;li&gt;&lt;i&gt;Word2Vec_models.zip&lt;/i&gt;: Archived version of the saved Word2Vec models, both unaligned and aligned.&lt;/li&gt;&lt;li&gt;&lt;i&gt;08 Word2Vec work with aligned models.py&lt;/i&gt;: Python script which loads the trained Word2Vec models to trace the development of the embeddings for the terms \u201csustainability\u201d and \u201cprofitability\u201d over time.&lt;/li&gt;&lt;li&gt;&lt;i&gt;99 Scrape further levels down.py&lt;/i&gt;: Python script that can be used to generate a list of unscraped URLs from the pages that themselves were one level deeper than the front page.&lt;/li&gt;&lt;li&gt;&lt;i&gt;URLs_2_deeper.csv&lt;/i&gt;: CSV file containing unscraped URLs from the pages that themselves were one level deeper than the front page.&lt;/li&gt;&lt;/ul&gt;&lt;p dir=\"ltr\"&gt;&lt;b&gt;For those only interested in downloading the final database of texts, the files \"HTML.zip\", \"TXT_uncleaned.zip\", \"TXT_cleaned.zip\", and \"TXT_combined.zip\" contain the full set of HTML pages, the processed but uncleaned texts, the selected and cleaned texts, and combined and cleaned texts at the GVKEY/year level, respectively.&lt;/b&gt;&lt;/p&gt;&lt;p dir=\"ltr\"&gt;The following webpage contains answers to frequently asked questions: https://haans-mertens.github.io/faq/. More information on the database and the underlying project can be found here: https://haans-mertens.github.io/ and the following article: \u201c&lt;i&gt;The Internet Never Forgets: A Four-Step Scraping Tutorial, Codebase, and Database for Longitudinal Organizational Website Data&lt;/i&gt;\u201d, by Richard F.J. Haans and Marc J. Mertens in &lt;i&gt;Organizational Research Methods&lt;/i&gt;. The full paper can be accessed &lt;a href=\"https://journals.sagepub.com/doi/10.1177/10944281241284941\" target=\"_blank\"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p dir=\"ltr\"&gt;&lt;br&gt;&lt;/p&gt;
description: Online resource. https://doi.org/10.25397/eur.17136383