-
Notifications
You must be signed in to change notification settings - Fork 22
Update the Etherscan scraper #4789
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -75,7 +75,6 @@ defmodule Sanbase.ExternalServices.Etherscan.Scraper do | |||||||||||
| | total_supply: total_supply(html) || project_info.total_supply, | ||||||||||||
| main_contract_address: project_info.main_contract_address || main_contract_address(html), | ||||||||||||
| token_decimals: project_info.token_decimals || token_decimals(html), | ||||||||||||
| website_link: project_info.website_link || website_link(html), | ||||||||||||
| email: project_info.email || official_link(html, "Email") |> email(), | ||||||||||||
| reddit_link: project_info.reddit_link || official_link(html, "Reddit"), | ||||||||||||
| twitter_link: project_info.twitter_link || official_link(html, "Twitter"), | ||||||||||||
|
|
@@ -89,16 +88,67 @@ defmodule Sanbase.ExternalServices.Etherscan.Scraper do | |||||||||||
| } | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| defp website_link(html) do | ||||||||||||
| Floki.find(html, ~s/#ContentPlaceHolder1_tr_officialsite_1 > div > div.col-md-8 > a/) | ||||||||||||
| |> Floki.attribute("href") | ||||||||||||
| |> List.first() | ||||||||||||
| end | ||||||||||||
|
|
||||||||||||
| defp official_link(html, media) do | ||||||||||||
| Floki.find(html, ~s/a[data-original-title^="#{media}:"]/) | ||||||||||||
| |> Floki.attribute("href") | ||||||||||||
| |> List.first() | ||||||||||||
| case media do | ||||||||||||
| "Reddit" -> | ||||||||||||
| Floki.find(html, "a[href*='reddit.com']") | ||||||||||||
| |> Floki.attribute("href") | ||||||||||||
| |> List.first() | ||||||||||||
|
|
||||||||||||
| "Twitter" -> | ||||||||||||
| Floki.find(html, "a[href*='twitter.com'], a[href*='x.com']") | ||||||||||||
| |> Floki.attribute("href") | ||||||||||||
| |> List.first() | ||||||||||||
|
|
||||||||||||
| "Bitcointalk" -> | ||||||||||||
| Floki.find(html, "a[href*='bitcointalk.org']") | ||||||||||||
| |> Floki.attribute("href") | ||||||||||||
| |> List.first() | ||||||||||||
|
|
||||||||||||
| "Blog" -> | ||||||||||||
| Floki.find(html, "a[href*='blog'], a[href*='medium.com'], a[href*='substack.com']") | ||||||||||||
| |> Enum.find(fn link -> | ||||||||||||
| href = Floki.attribute(link, "href") |> List.first() | ||||||||||||
| href && !String.contains?(href, "etherscan-blog") | ||||||||||||
| end) | ||||||||||||
| |> case do | ||||||||||||
| nil -> nil | ||||||||||||
| link -> Floki.attribute(link, "href") |> List.first() | ||||||||||||
| end | ||||||||||||
|
||||||||||||
| end | |
| |> Floki.attribute("href") | |
| |> Enum.find(fn href -> | |
| href && !String.contains?(href, "etherscan-blog") | |
| end) |
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Floki.find/2 on an h4 element to find nested 'b' tags may not work as expected. The h4 variable contains a single HTML element, but Floki.find/2 typically expects an HTML document or fragment. Consider using a different approach to extract the bold text from within the h4 element.
| Floki.find(h4, "b") | |
| Floki.find([h4], "b") |
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function removes the logic that previously parsed 'Supply:' prefix from the total supply string but retains the binary guard. This could cause parsing issues if the input format still contains text prefixes that need to be stripped before converting to Decimal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is removed as I couldn't find a proper way to extract the website URL from the HTML.