Jul 10, 2019 12:11 PM
(This post was last modified: Jul 10, 2019 03:56 PM by Kallu609.)
Made this while ago and decided to share because I don't really have need for this. Maybe this will help someone.
E: Updated multiple times. This post has most up-to-date version
(Jul 10, 2019 12:11 PM)Kallu609 Wrote: Made this while ago and decided to share because I don't really have need for this. Maybe this will help someone.
so it just goes through a textfile and checks to see if the account is banned or not? what was your reasoning for first starting out the project
Jul 10, 2019 12:22 PM
(This post was last modified: Jul 10, 2019 12:25 PM by Kallu609.)
(Jul 10, 2019 12:19 PM)rabbi Wrote: so it just goes through a textfile and checks to see if the account is banned or not? what was your reasoning for first starting out the project
I got request from fellow HF user to make program for him to mass check his accounts. I wouldn't call this a "project", a snippet at most.
I struggled a lot on beginning of my Python career with multithreading, hopefully this will help someone. It really isn't as hard as it first seems.
(Jul 10, 2019 12:22 PM)Kallu609 Wrote: I got request from fellow HF user to make program for him to mass check his accounts. I wouldn't call this a "project", a snippet at most.
I struggled a lot on beginning of my Python career with multithreading, hopefully this will help someone. It really isn't as hard as it first seems.
ah i see, glad you could help someone out
Jul 10, 2019 03:04 PM
(This post was last modified: Jul 10, 2019 03:05 PM by l0lwtf.)
Code with lock:
print(username.ljust(26, " ") + status)
if not is_banned:
open(not_banned_file, 'a').write(item + '\n')
Does this close the file handle correctly? I don't think so? Maybe I'm mistaken due to the 'with'.
Jul 10, 2019 03:56 PM
(This post was last modified: Jul 10, 2019 04:02 PM by Kallu609.)
(Jul 10, 2019 03:04 PM)l0lwtf Wrote: Code with lock:
print(username.ljust(26, " ") + status)
if not is_banned:
open(not_banned_file, 'a').write(item + '\n')
Does this close the file handle correctly? I don't think so? Maybe I'm mistaken due to the 'with'.
You're right. It doesn't close the file handle properly. I updated main post for better version.
Thanks for this Kallu, I'm pretty new to python but this looks pretty handy. I never really thought about multithreading, I'm going to go through your code and comment some of the lines to try and better understand it.
DO NOT DEAL WITH THIS MEMBER
I like making Twitch related scripts too. You might want to add a 1 second delay between each request to avoid rate limit issues.
(Jul 12, 2019 04:50 AM)datguy.dev Wrote: I like making Twitch related scripts too. You might want to add a 1 second delay between each request to avoid rate limit issues.
I don't know if there's any. I ran 100s of requests and it still gave the right response so I think you can abuse that API endpoint all you want.
DO NOT DEAL WITH THIS MEMBER
(Jul 12, 2019 05:55 AM)Kallu609 Wrote: I don't know if there's any. I ran 100s of requests and it still gave the right response so I think you can abuse that API endpoint all you want.
They have never really posted an official API rate limit tat I've seen. But there is code there as I've been hit with the "Rate Limit Exceeded" response. If you to become a problem, I'm sure they would ban your client id or IP. It's just a good practice to not beat on APIs if you don't have to.
r.text looks like a JSON response any reason you're not loading it into a dictionary?
¸„»°'´¸„»°'´Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est ¸„»°'´`'°«„¸`'°«„¸¸„»°'´
(Jul 14, 2019 07:40 AM)vorticalbox Wrote: r.text looks like a JSON response any reason you're not loading it into a dictionary?
It's more efficient to just read few characters from start of string than parsing JSON and checking it's value.
(Jul 14, 2019 12:51 PM)Kallu609 Wrote: It's more efficient to just read few characters from start of string than parsing JSON and checking it's value.
doesn't it all ready have it as json? which you can access via .json()
¸„»°'´¸„»°'´Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est ¸„»°'´`'°«„¸`'°«„¸¸„»°'´
Jul 15, 2019 02:56 AM
(This post was last modified: Jul 15, 2019 02:58 AM by Kallu609.)
(Jul 15, 2019 02:27 AM)vorticalbox Wrote: doesn't it all ready have it as json? which you can access via .json()
Yes, it does have it as JSON but JSON parsing is slow.
Here's example running 1000000 iterations:
(Jul 15, 2019 02:56 AM)Kallu609 Wrote: Yes, it does have it as JSON but JSON parsing is slow.
Here's example running 1000000 iterations:
![[Image: y0zUZY6.png]](https://i.imgur.com/y0zUZY6.png)
fair enough I thought the request library already did the json.parse for you 👍
¸„»°'´¸„»°'´Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est ¸„»°'´`'°«„¸`'°«„¸¸„»°'´
|