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
|
Birthday string
|
||||||
FollowersCount int
|
FollowersCount int
|
||||||
FollowingCount int
|
FollowingCount int
|
||||||
|
IsPrivate bool
|
||||||
|
IsVerified bool
|
||||||
Joined *time.Time
|
Joined *time.Time
|
||||||
LikesCount int
|
LikesCount int
|
||||||
Location string
|
Location string
|
||||||
Name string
|
Name string
|
||||||
TweetsCount int
|
TweetsCount int
|
||||||
URL string
|
URL string
|
||||||
|
UserID string
|
||||||
Username string
|
Username string
|
||||||
Website 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 ", ""),
|
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()),
|
||||||
FollowingCount: parseCount(doc.Find(".ProfileNav-item--following > 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,
|
Joined: &joined,
|
||||||
LikesCount: parseCount(doc.Find(".ProfileNav-item--favorites > a > span.ProfileNav-value").First()),
|
LikesCount: parseCount(doc.Find(".ProfileNav-item--favorites > a > span.ProfileNav-value").First()),
|
||||||
Location: location,
|
Location: location,
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,17 @@ func TestGetProfile(t *testing.T) {
|
||||||
loc := time.FixedZone("UTC", 0)
|
loc := time.FixedZone("UTC", 0)
|
||||||
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",
|
||||||
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",
|
||||||
Joined: &joined,
|
IsPrivate: false,
|
||||||
Location: "Everywhere",
|
IsVerified: true,
|
||||||
Name: "Twitter",
|
Joined: &joined,
|
||||||
URL: "https://twitter.com/Twitter",
|
Location: "Everywhere",
|
||||||
Username: "Twitter",
|
Name: "Twitter",
|
||||||
Website: "https://about.twitter.com/",
|
URL: "https://twitter.com/Twitter",
|
||||||
|
Username: "Twitter",
|
||||||
|
Website: "https://about.twitter.com/",
|
||||||
}
|
}
|
||||||
|
|
||||||
profile, err := GetProfile("Twitter")
|
profile, err := GetProfile("Twitter")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue