simplify social code
このコミットが含まれているのは:
コミット
ba642bf695
|
@ -25,10 +25,7 @@ type User struct {
|
|||
Following int64
|
||||
Followers int64
|
||||
Link string
|
||||
Link1 string
|
||||
Link2 string
|
||||
Link3 string
|
||||
Link4 string
|
||||
Social []string
|
||||
Company string
|
||||
Type string
|
||||
Contributions string
|
||||
|
@ -144,18 +141,8 @@ func HandleUser(c *fiber.Ctx) error {
|
|||
Scrape.Location = e.ChildText("li[itemprop*='homeLocation'] span")
|
||||
Scrape.Timezone = e.ChildText("li[itemprop*='localTime'] span")
|
||||
Scrape.Company = e.ChildText("li[itemprop*='worksFor'] span")
|
||||
// I know this is hacky, I'll get around to fixing it later -arya
|
||||
e.ForEach("li[itemprop*='social']", func(i int, el *colly.HTMLElement) {
|
||||
switch i {
|
||||
case 0:
|
||||
Scrape.Link1 = el.ChildText("a.Link--primary")
|
||||
case 1:
|
||||
Scrape.Link2 = el.ChildText("a.Link--primary")
|
||||
case 2:
|
||||
Scrape.Link3 = el.ChildText("a.Link--primary")
|
||||
case 3:
|
||||
Scrape.Link4 = el.ChildText("a.Link--primary")
|
||||
}
|
||||
Scrape.Social = append(Scrape.Social, el.ChildText("a.Link--primary"))
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
@ -26,18 +26,11 @@
|
|||
{{ if .Link }}
|
||||
<p>🌐 <a href="https://{{.Link}}" target="_blank">{{.Link}}</a></p>
|
||||
{{ end }}
|
||||
{{ if .Link1 }}
|
||||
<p>🔗 <a href="https://{{.Link1}}" target="_blank">{{.Link1}}</a></p>
|
||||
{{ end }}
|
||||
{{ if .Link2 }}
|
||||
<p>🔗 <a href="https://{{.Link2}}" target="_blank">{{.Link2}}</a></p>
|
||||
{{ end }}
|
||||
{{ if .Link3 }}
|
||||
<p>🔗 <a href="https://{{.Link3}}" target="_blank">{{.Link3}}</a></p>
|
||||
{{ end }}
|
||||
{{ if .Link4 }}
|
||||
<p>🔗 <a href="https://{{.Link4}}" target="_blank">{{.Link4}}</a></p>
|
||||
{{ end }}
|
||||
{{ if .Social }}
|
||||
{{range .Social}}
|
||||
<p>🔗 <a href="{{.}}" target="_blank">{{.}}</a></p>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if .Company }}
|
||||
<p>🏢 {{.Company}}</p>
|
||||
{{ end }}
|
||||
|
|
読み込み中…
新しいイシューから参照