Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds script to discover identifiers missing from Appsflyer's public sheet #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/Appsflyer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
beautifulsoup4=4.9.1
requests==2.7.0
56 changes: 56 additions & 0 deletions scripts/Appsflyer/scrape_appsflyer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import requests
import re

from bs4 import BeautifulSoup

def scrape_appsflyer():
request = requests.get("https://docs.google.com/spreadsheets/d/e/2PACX-1vSqwIBW3FzbrXKqluDQ2hEec7zcvVrxQ02ivWsHnGQTvLMeFmHHjGz1R5TVy6_cqAIVh0pAy4Yud7Qx/pubhtml#")
soup = BeautifulSoup(request.content, "html5lib")
# print(soup.prettify())

discovered_networks = []

sheets_viewport = soup.find("div", attrs = { "id": "sheets-viewport" })
sheets_table = sheets_viewport.find("tbody")

for sheets_row in sheets_table.findAll("tr")[1:]:
sheets_row_group = sheets_row.findAll("td")

if len(sheets_row_group) != 2:
continue

network = {}
network["name"] = sheets_row_group[0].text
network["network"] = sheets_row_group[1].text

if not network["name"] or not network["network"]:
continue

discovered_networks.append(network)

return discovered_networks

def filter_not_found_in_readme(networks):
filtered_networks = []

with open("README.md") as readme_file:
readme = readme_file.read()

for network in networks:
if re.search(r"\\|%s" % network["network"].split(".")[0], readme, re.MULTILINE) == None:
filtered_networks.append(network)

return filtered_networks


appsflyer_networks = scrape_appsflyer()
networks_missing_from_readme = filter_not_found_in_readme(appsflyer_networks)

# for network in appsflyer_networks:
# print("Discovered Network: %s [%s]" % (network["name"], network["network"]))

print("Found %i networks, %i require addition." % (len(appsflyer_networks), len(networks_missing_from_readme)))
print("Networks requiring readme addition:")

for network in networks_missing_from_readme:
print("|[%s]()|%s||" % (network["name"].split("_")[0], network["network"].split(".")[0]))