Skip to content

Commit

Permalink
add tag parse
Browse files Browse the repository at this point in the history
  • Loading branch information
superwunc committed Jul 2, 2024
1 parent 108ae73 commit 09f88e8
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 2 deletions.
182 changes: 182 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
},
"dependencies": {
"@actions/core": "^1.10.1",
"cheerio": "^1.0.0-rc.12",
"got": "^14.4.1",
"lodash": "^4.17.21",
"node-fetch": "^3.3.2"
Expand Down
22 changes: 20 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from '@actions/core'

import * as cheerio from 'cheerio';

Check failure on line 2 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Delete `;`

Check failure on line 2 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Extra semicolon
import fs from 'node:fs'
import _ from 'lodash'
const WHITE_ADDRESS = [
Expand Down Expand Up @@ -64,6 +64,22 @@ function getFiles(dir: string, files: string[] = []) {
}
return files
}

async function fetchBscScanTag(address: string) {
try {
const reponse = await fetch(`https://bscscan.com/address/${address}`);
if (reponse.ok) {
const text = await reponse.text();
const $ = cheerio.load(text);
const tags = $('#ContentPlaceHolder1_divLabels .hash-tag').text();
console.log("tags", tags)
return tags;
}
}
catch(error) {
return [];
}
}
/**
* The main function for the action.
* @returns {Promise<void>} Resolves when the action is complete.
Expand All @@ -90,6 +106,7 @@ export async function run(): Promise<void> {
}
}
const contractAddressGroup = _.chunk(Array.from(allContractAddress), 5)

if (contractAddressGroup.length > 0) {
for (let i = 0, l = contractAddressGroup.length; i < l; i++) {
const contractAddress = contractAddressGroup[i]
Expand All @@ -101,11 +118,12 @@ export async function run(): Promise<void> {
if (response.ok) {
const data: any = await response.json()
if (data.status === '1') {
data.result.forEach((item: any) => {
data.result.forEach(async (item: any) => {
if (!DeployList.includes(item.contractCreator.toLowerCase())) {
console.log(
`BSC\thttps://bscscan.com/address/${item.contractAddress}\t${item.contractCreator}`
)
await fetchBscScanTag(item.contractAddress)
}
})
}
Expand Down

0 comments on commit 09f88e8

Please sign in to comment.