-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyc_traffic3.py
More file actions
33 lines (25 loc) · 796 Bytes
/
Copy pathyc_traffic3.py
File metadata and controls
33 lines (25 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pandas as pd
from playwright.sync_api import sync_playwright
import json
from urllib.parse import urlparse
df = pd.read_csv("yc_w26_startups.csv")
def domain(url):
return urlparse(url).netloc.replace("www.","")
results = []
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
def handle_response(response):
if "similarweb.com/api" in response.url:
try:
data = response.json()
print(data)
except:
pass
page.on("response", handle_response)
for _, row in df.iterrows():
d = domain(row["website"])
url = f"https://www.similarweb.com/website/{d}/"
print("Visiting", d)
page.goto(url)
browser.close()