Add banner photo in profile
This commit is contained in:
parent
7e8d3badb4
commit
87fdf1c10e
2 changed files with 3 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ import (
|
||||||
// Profile of twitter user.
|
// Profile of twitter user.
|
||||||
type Profile struct {
|
type Profile struct {
|
||||||
Avatar string
|
Avatar string
|
||||||
|
Banner string
|
||||||
Biography string
|
Biography string
|
||||||
Birthday string
|
Birthday string
|
||||||
FollowersCount int
|
FollowersCount int
|
||||||
|
|
@ -65,6 +66,7 @@ func GetProfile(username string) (Profile, error) {
|
||||||
|
|
||||||
return Profile{
|
return Profile{
|
||||||
Avatar: doc.Find(".ProfileAvatar-image").First().AttrOr("src", ""),
|
Avatar: doc.Find(".ProfileAvatar-image").First().AttrOr("src", ""),
|
||||||
|
Banner: doc.Find(".ProfileCanopy-headerBg img").First().AttrOr("src", ""),
|
||||||
Biography: doc.Find(".ProfileHeaderCard-bio.u-dir").First().Text(),
|
Biography: doc.Find(".ProfileHeaderCard-bio.u-dir").First().Text(),
|
||||||
Birthday: strings.ReplaceAll(strings.TrimSpace(doc.Find(".ProfileHeaderCard-birthdateText.u-dir").First().Text()), "Born ", ""),
|
Birthday: strings.ReplaceAll(strings.TrimSpace(doc.Find(".ProfileHeaderCard-birthdateText.u-dir").First().Text()), "Born ", ""),
|
||||||
FollowersCount: parseCount(doc.Find(".ProfileNav-item--followers > a > span.ProfileNav-value").First()),
|
FollowersCount: parseCount(doc.Find(".ProfileNav-item--followers > a > span.ProfileNav-value").First()),
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ func TestGetProfile(t *testing.T) {
|
||||||
joined := time.Date(2007, 02, 20, 6, 35, 0, 0, loc)
|
joined := time.Date(2007, 02, 20, 6, 35, 0, 0, loc)
|
||||||
sample := Profile{
|
sample := Profile{
|
||||||
Avatar: "https://pbs.twimg.com/profile_images/1270500941498912768/W-80pLvu_400x400.jpg",
|
Avatar: "https://pbs.twimg.com/profile_images/1270500941498912768/W-80pLvu_400x400.jpg",
|
||||||
|
Banner: "https://pbs.twimg.com/profile_banners/783214/1590856275/1500x500",
|
||||||
Biography: "Black queer lives matter.\nBlack trans lives matter.\n#BlackLivesMatter",
|
Biography: "Black queer lives matter.\nBlack trans lives matter.\n#BlackLivesMatter",
|
||||||
Birthday: "March 21",
|
Birthday: "March 21",
|
||||||
IsPrivate: false,
|
IsPrivate: false,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue