mirror of
https://codeberg.org/gothub/gothub
synced 2024-12-06 19:16:24 +01:00
cleanup the code a bit more
This commit is contained in:
+12
-15
@@ -100,16 +100,26 @@ func HandleUser(c *fiber.Ctx) error {
|
||||
}
|
||||
}
|
||||
// scraping
|
||||
var Scrape User
|
||||
var OrgOrUser string
|
||||
|
||||
Scrape := User{
|
||||
Link: link,
|
||||
Type: user.Get("type").String(),
|
||||
EwTwitter: user.Get("twitter_username").String(),
|
||||
Readme: string(readmeOutput),
|
||||
}
|
||||
|
||||
sc1 := colly.NewCollector(colly.AllowedDomains("github.com"))
|
||||
|
||||
sc1.OnHTML("div[itemtype]", func(e *colly.HTMLElement) {
|
||||
OrgOrUser = e.Attr("itemtype")
|
||||
})
|
||||
|
||||
sc1.Visit("https://github.com/" + c.Params("user") + "/")
|
||||
sc := colly.NewCollector(
|
||||
colly.AllowedDomains("github.com"),
|
||||
)
|
||||
|
||||
if OrgOrUser == "http://schema.org/Person" {
|
||||
// Bio
|
||||
sc.OnHTML("div[data-bio-text]", func(e *colly.HTMLElement) {
|
||||
@@ -144,20 +154,7 @@ func HandleUser(c *fiber.Ctx) error {
|
||||
log.Println("Bio and Location routes cannot be scraped for organizations")
|
||||
}
|
||||
sc.Visit("https://github.com/" + c.Params("user") + "/")
|
||||
userArray = append(userArray, User{
|
||||
Login: Scrape.Login,
|
||||
Name: Scrape.Name,
|
||||
Bio: Scrape.Bio,
|
||||
AvatarUrl: Scrape.AvatarUrl,
|
||||
Location: Scrape.Location,
|
||||
Following: Scrape.Following,
|
||||
Followers: Scrape.Followers,
|
||||
Link: link,
|
||||
Company: Scrape.Company,
|
||||
Type: user.Get("type").String(),
|
||||
EwTwitter: user.Get("twitter_username").String(),
|
||||
Readme: string(readmeOutput),
|
||||
})
|
||||
userArray = append(userArray, scrape)
|
||||
|
||||
fmt.Println(userArray)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user