Hi
is there a way in AHK to get the Twitter Follow Count of a user and put it in a variable
thanks a lot
Get Twitter Follow Count Topic is solved
Re: Get Twitter Follow Count
Code: Select all
MsgBox, 64, CNN Followers, % followers := twitterFollowers("cnnbrk")
twitterFollowers(screenName) { ; https://www.autohotkey.com/boards/viewtopic.php?p=431740#p431740
Static url := "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names="
Try whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
Catch
Return
whr.SetTimeouts(0, 30000, 30000, 600000), whr.Open("GET", url StrReplace(screenName, "@"), False)
Try {
whr.Send()
Sleep, 100
RegExMatch(whr.ResponseText, """followers_count"":\K\d+", followers)
}
Return followers
}
Re: Get Twitter Follow Count
thx @mikeyww this script looks nice
bot for me it not work i just get this
bot for me it not work i just get this
- Attachments
-
- notepad++_VcsE7gmDy8.jpg (3.22 KiB) Viewed 1522 times
Re: Get Twitter Follow Count
I just ran this exact script and saw the following.
AHK version: 1.1.33.10
AHK version: 1.1.33.10
Re: Get Twitter Follow Count
i also have Version 1.1.30.01
hmmm?
any idea whats wrong?
hmmm?
any idea whats wrong?
Re: Get Twitter Follow Count
Sorry I do not know what issue you are having. I believe that Twitter has a v2 API available upon registration. That might enable you to do the same thing. I have not tested it.
If you remove the Try command itself, it may enable you to see an error message if there is one.
You may also wish to see what happens if you paste the following URL into your Chrome browser.
https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=cnnbrk
At my end, this downloads a file called json.json. It contains content similar to the following.
[{"following":false,"id":"428333","screen_name":"cnnbrk","name":"CNN Breaking News","protected":false,"followers_count":61686905,"formatted_followers_count":"61.7M followers","age_gated":false}]
The script simply gets that text and reads the followers count from it.
If the Sleep, 100 is too short at your end, the process might fail, though I don't think it would. You could increase 100 to 500 or more, to see whether that makes a difference.
If you remove the Try command itself, it may enable you to see an error message if there is one.
Code: Select all
MsgBox, 64, CNN Followers, % followers := twitterFollowers("cnnbrk")
twitterFollowers(screenName) { ; https://www.autohotkey.com/boards/viewtopic.php?p=431740#p431740
Static url := "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names="
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.SetTimeouts(0, 30000, 30000, 600000), whr.Open("GET", url StrReplace(screenName, "@"), False)
whr.Send()
Sleep, 100
RegExMatch(whr.ResponseText, """followers_count"":\K\d+", followers)
Return followers
}
https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=cnnbrk
At my end, this downloads a file called json.json. It contains content similar to the following.
[{"following":false,"id":"428333","screen_name":"cnnbrk","name":"CNN Breaking News","protected":false,"followers_count":61686905,"formatted_followers_count":"61.7M followers","age_gated":false}]
The script simply gets that text and reads the followers count from it.
If the Sleep, 100 is too short at your end, the process might fail, though I don't think it would. You could increase 100 to 500 or more, to see whether that makes a difference.
Re: Get Twitter Follow Count
Yes, if I paste the URL into the browser, then I get the file with the follow count
on the script I get an error now, check the pic in attached file
i also did higher sleep did not help
well, I compiled your script to .exe and tried it on my laptop and on a friend's PC , and there it works... so I guess there is some wrong setting in my windows
on the script I get an error now, check the pic in attached file
i also did higher sleep did not help
well, I compiled your script to .exe and tried it on my laptop and on a friend's PC , and there it works... so I guess there is some wrong setting in my windows
- Attachments
-
- AutoHotkey_jKMhKd06eM.jpg (29.28 KiB) Viewed 1362 times
Re: Get Twitter Follow Count
It could be your firewall settings that doesn’t allow for the Send() to occur.
Re: Get Twitter Follow Count
I agree with boiler. Antivirus is sometimes an issue as well-- easy enough to disable it and test again. Finally, running as admin is also easy to try.
Re: Get Twitter Follow Count
I removed firewall and antivirus for test , also I do run as admin... still same
anyway I run it on my laptop now there it works fine
I have an additional question to your script: how I can read out the twitter name
my guess was like this, but not work, maybe u have an idea?
anyway I run it on my laptop now there it works fine
I have an additional question to your script: how I can read out the twitter name
my guess was like this, but not work, maybe u have an idea?
Code: Select all
twitterFollowers(screenName) { ; https://www.autohotkey.com/boards/viewtopic.php?p=431740#p431740
Static url := "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names="
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.SetTimeouts(0, 30000, 30000, 600000), whr.Open("GET", url StrReplace(screenName, "@"), False)
whr.Send()
Sleep, 3333
RegExMatch(whr.ResponseText, """name"":\K\d+", followers)
Return followers
}
Re: Get Twitter Follow Count Topic is solved
Code: Select all
#Include d:\utils\JSON.ahk ; https://github.com/cocobelgica/AutoHotkey-JSON
tw := twitter("cnnbrk")
MsgBox, 64, Twitter results, % "Name : " tw.name "`nFollowers: " tw.followers_count
twitter(screenName) { ; https://www.autohotkey.com/boards/viewtopic.php?p=431740#p431740
Static url := "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names="
whr := ComObjCreate("WinHttp.WinHttpRequest.5.1")
whr.SetTimeouts(0, 30000, 30000, 600000), whr.Open("GET", url StrReplace(screenName, "@"), False)
whr.Send()
Sleep, 100
Return JSON.Load(whr.ResponseText).1
}
Re: Get Twitter Follow Count
This sounds like you are saying that your Windows user account has admin privileges (sorry, and ignore if not). That is not what is being suggested and does not matter. If you haven’t yet, try running the script itself as administrator by right-clicking on the script file in File Explorer and selecting “Run as administrator.” That causes the script to run as an “elevated process,” which doesn’t happen just because the user is an admin.
Re: Get Twitter Follow Count
thanks this was very helpful
I installed the Easy fix from microsoft.com and this fixed the problem
Re: Get Twitter Follow Count
great, thanks a lot for your timemikeyww wrote: ↑01 Dec 2021, 06:50Code: Select all
#Include d:\utils\JSON.ahk ; https://github.com/cocobelgica/AutoHotkey-JSON tw := twitter("cnnbrk") MsgBox, 64, Twitter results, % "Name : " tw.name "`nFollowers: " tw.followers_count twitter(screenName) { ; https://www.autohotkey.com/boards/viewtopic.php?p=431740#p431740 Static url := "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=" whr := ComObjCreate("WinHttp.WinHttpRequest.5.1") whr.SetTimeouts(0, 30000, 30000, 600000), whr.Open("GET", url StrReplace(screenName, "@"), False) whr.Send() Sleep, 100 Return JSON.Load(whr.ResponseText).1 }
image211201-0646-001d.png
do you know if there are more .json files on Twitter I can download, for example how much user an account Follow or how much like in Total
Re: Get Twitter Follow Count
I do not know.