Add IsPrivate and IsVerified for profile
This commit is contained in:
parent
52eb1f23df
commit
5a6607f6c4
2 changed files with 16 additions and 9 deletions
|
|
@ -17,12 +17,15 @@ type Profile struct {
|
|||
Birthday string
|
||||
FollowersCount int
|
||||
FollowingCount int
|
||||
IsPrivate bool
|
||||
IsVerified bool
|
||||
Joined *time.Time
|
||||
LikesCount int
|
||||
Location string
|
||||
Name string
|
||||
TweetsCount int
|
||||
URL string
|
||||
UserID string
|
||||
Username string
|
||||
Website string
|
||||
}
|
||||
|
|
@ -66,6 +69,8 @@ func GetProfile(username string) (Profile, error) {
|
|||
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()),
|
||||
FollowingCount: parseCount(doc.Find(".ProfileNav-item--following > a > span.ProfileNav-value").First()),
|
||||
IsPrivate: doc.Find(".ProfileHeaderCard-badges .Icon--protected").First().Text() != "",
|
||||
IsVerified: doc.Find(".ProfileHeaderCard-badges .Icon--verified").First().Text() != "",
|
||||
Joined: &joined,
|
||||
LikesCount: parseCount(doc.Find(".ProfileNav-item--favorites > a > span.ProfileNav-value").First()),
|
||||
Location: location,
|
||||
|
|
|
|||
|
|
@ -12,15 +12,17 @@ func TestGetProfile(t *testing.T) {
|
|||
loc := time.FixedZone("UTC", 0)
|
||||
joined := time.Date(2007, 02, 20, 6, 35, 0, 0, loc)
|
||||
sample := Profile{
|
||||
Avatar: "https://pbs.twimg.com/profile_images/1270500941498912768/W-80pLvu_400x400.jpg",
|
||||
Biography: "Black queer lives matter.\nBlack trans lives matter.\n#BlackLivesMatter",
|
||||
Birthday: "March 21",
|
||||
Joined: &joined,
|
||||
Location: "Everywhere",
|
||||
Name: "Twitter",
|
||||
URL: "https://twitter.com/Twitter",
|
||||
Username: "Twitter",
|
||||
Website: "https://about.twitter.com/",
|
||||
Avatar: "https://pbs.twimg.com/profile_images/1270500941498912768/W-80pLvu_400x400.jpg",
|
||||
Biography: "Black queer lives matter.\nBlack trans lives matter.\n#BlackLivesMatter",
|
||||
Birthday: "March 21",
|
||||
IsPrivate: false,
|
||||
IsVerified: true,
|
||||
Joined: &joined,
|
||||
Location: "Everywhere",
|
||||
Name: "Twitter",
|
||||
URL: "https://twitter.com/Twitter",
|
||||
Username: "Twitter",
|
||||
Website: "https://about.twitter.com/",
|
||||
}
|
||||
|
||||
profile, err := GetProfile("Twitter")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue