Repository navigation
Description
Hi all,
as previously announced in Slack, we wanted to classify the URLs, and we hope to have this solved soon. We classified over 110M different hostnames. In this issue, I want to give you an overview of the method we applied, and we have some discussion points to address.
How we classified and the results
We began by extracting distinct hostnames from all requests and extended the data with the domain name (eTLD+1) of these hostnames. This gave us a total of 110M distinct hostnames to classify. Using @yohhaan’s repository, which leverages the Google Topics API, we managed to classify 89% of the hostnames. 11% could not be classified due to the Topics API excluding adult sites (e.g., gambling). The dataset is currently hosted in my private project and can be queried:
SELECT * FROM
misc-researches.ha.ha_categories
Points to discuss
- Some hostnames should not be classified individually. For example, googlesyndication.com has 32 million different hostnames like
- 344e9ef099804fd8c68c0fed4854714e.safeframe.googlesyndication.com
- f47537a0041724dc8f0b439351fc3c47.safeframe.googlesyndication.com
- 8093dad3f60733da38ed196bb05dcf64.safeframe.googlesyndication.com
- 0bf6fcceca14ad5d5f814d945a6fbfc5.safeframe.googlesyndication.com
- c8831bbba893efe5174181d2fcedf255.safeframe.googlesyndication.com
The model's classification for these hostnames is very inconsistent, likely due to the hash values. Therefore, we should assign the classification of googlesyndication.com to all its hostnames. This issue also exists for other popular providers. I have created a sheet and manually assigned which popular sites with hashed subdomains should use the classification of the domain instead of the subdomain: Classification of sites with many subdomains.
- We need to decide how we want to provide the data. Should we maintain a table containing all entries with their classification? Additionally, we could provide a UDF to query the taxonomy of a given hostname, which can also help us maintain the logic discussed above.
- @rviscomi wants to integrate the classification during the crawling process. @yoohan can assist us with this integration
Many thanks to @yohhaan for his contributions throughout the entire process! He adjusted his repository and ran the scripts for the classification.
Activity
yohhaan commentedon May 31, 2024
Hello all,
Thanks @nrllh for this summary and for the resources provided to classify these hostnames.
Some ideas:
Unknown). Also, the version of the Topics model used (latest: chrome5) should be encoded somehow (maybe just in the name of the table?).I would then release a second table listing the corrections you have started to manually map (eTLD+1 with corresponding topics). That way, we can then do as you describe: write a joint SQL query/UDF that returns the (corrected) classification that the HTTP archive would like to use.
I suppose the process previously described in 1. would work for the almanac 2024, but moving forward if you want to classify during each crawl (like per 3.) the structure may have to be a bit different.
I made public the setup and script I used for this classification: https://github.com/yohhaan/httparchive-topics-classification for future reference. @rviscomi ping me if you need help/have questions.
rviscomi commentedon Jun 10, 2024
Spoke with @pmeenan about this and for now we're hesitant to add this directly into the crawl for maintainability reasons. For unblocking the Web Almanac analysis, we could either host the classifications directly in HTTP Archive's BigQuery project, or if @yohhaan is willing to host it, he'd just need to open up public access to the existing table. My preference would be to host it on HTTP Archive so that we'd absorb any storage costs / maintenance burden. WDYT?
If we do store the unprocessed classifications, I like the idea of using a persistent UDF, maybe something like
httparchive.fn.CLASSIFY_HOSTNAME. We could add reusable logic there to handle the googlesyndication edge case and so on. I'd imagine that this is mostly affected by subresources rather than document URLs, so if the UDF adds too much overhead we might want to consider storing the post-processed classifications or having a second UDF for documents.Longer term, we could re-explore classifying as part of the crawl. We should also re-explore classifying hosts using BigQuery ML, which would let us analyze older crawls.
nrllh commentedon Jun 27, 2024
I processed the hosts from the last crawl as well. We now have what we all need. I've also spoken with @yohhaan, and we would like to store the data in HA's project. You can access the data via:
The table consists of 5 columns:
I also created a UDF to retrieve the category for a given host. The function has two parameters: input_host and row_results. The row_results parameter addresses our discussion about hashed subdomains. When row_results is set to false, the function checks if the host's domain is among the top 50 domains known for hashed subdomains. If so, it returns the category of the domain instead of the hostname. The function returns an array of JSON with the host, category ID, full category, subcategory, and parent category. We may also want to retrieve only full category of the hostnames. Note that we have for some hostnames multiple categories that's why we need to handle that.
rviscomi commentedon Jun 27, 2024
This is great, thanks!
I've cloned the data into
httparchive.urls.categories:I've also saved the persistent UDF to
httparchive.fn.GET_HOST_CATEGORIESwith a couple of changes:categoriestable in the HA projectHere's the query:
Example usage:
Results:
[{ "host": "npr.org", "category_id": "23", "full_category": "/Arts \u0026 Entertainment/Music \u0026 Audio", "subcategory": "Music \u0026 Audio", "parent_category": "/Arts \u0026 Entertainment/" }, { "host": "npr.org", "category_id": "243", "full_category": "/News", "subcategory": "News", "parent_category": "/News" }]@nrllh I'm not so sure about the
row_resultsparam. Is it ever useful to look up hosts like1234.googlesyndication.com? Why not unconditionally map these hosts to their domain, something likeWHEN net.reg_domain(input_host) IN ...?nrllh commentedon Jun 28, 2024
Thank you.
I agree,
row_resultswas unnecessary. We can indeed map these hosts directly to their domains.Changes made:
formatted_input_hostto ensure the input is correctly formatted, allowing the function to handle also full URLs.row_results.I'll prepare a document for har.fyi so we can announce it. Please let me know once you have updated the function.
rviscomi commentedon Jun 28, 2024
Updated!
[{ "host": "apple.com", "category_id": "528", "full_category": "/Internet \u0026 Telecom/Mobile Phones", "subcategory": "Mobile Phones", "parent_category": "/Internet \u0026 Telecom/" }, { "host": "apple.com", "category_id": "129", "full_category": "/Computers \u0026 Electronics/Consumer Electronics", "subcategory": "Consumer Electronics", "parent_category": "/Computers \u0026 Electronics/" }]max-ostapenko commentedon Jun 9, 2025
@nrllh a question regarding the table - httparchive.urls.categories
It hasn't been updated since last Almanac. And was used just for analysis, not linked anywhere in the chapters.
Will we need it for this year?
nrllh commentedon Jun 9, 2025
Some researchers use this table; we also announce it here: https://har.fyi/reference/functions/get_host_categories/.
We can update the table instead of removing it.
cc'ing @yohhaan
yohhaan commentedon Jun 9, 2025
The code used last year to classify all these domains is linked in the above comment: #868 (comment)
Let me know how you would like to proceed and how I could be of help.
nrllh commentedon Jun 9, 2025
I think the current model is more reliable at classifying the URLs? If so we should consider updating the table. WDYT?
yohhaan commentedon Jun 9, 2025
The model has not changed since last year's classification (still version 5), so we would just have to classify the new URLs that were not included in last year's URLs dump.
nrllh commentedon Jun 9, 2025
Thank you. I thought there were some improvements, but you are right, it still uses the same taxonomy and model.
I'll extract the new URLs. Would you be able then to process them?
yohhaan commentedon Jun 9, 2025
For sure, ping me when you have them.
nrllh commentedon Jun 9, 2025
thank you!
max-ostapenko commentedon Jun 10, 2025
@nrllh If it's to be regularly used, we can deploy this and trigger as part of our crawl pipeline when required.