Hi guys
Many of us struggle to focus nowadays, easily distracted by Social media and some sites on the internet which dramatically affecting our p...
For further actions, you may consider blocking this person and/or reporting abuse
neat article thanks for sharing. an alternative approach is to create a hosts.blocked file. then use a cron job (or python) to simply swap the files:
create two files:
hosts.original (copy of original etc hosts)
hosts.blocked (original + deadend for blocked sites)
(on)
copy hosts.blocked to etc hosts
(off)
copy hosts.original to etc hosts
this will ensure you are not mutating the original file. you can then convert your tool to generate the .blocked file based on that list of sites (auto appending common prefixes like www)
Hello. I registered on the website newly in order to get some help about this blog. Firstly, this article is so understandable including code part. However, questions are inevitable. I spent several hours to understand the project, but couldn't get why we should use truncate(), seek(), and write() (to rewrite) in "else" part. I searched how the first two functions work, and tried trial and error tactics to understand the functionality of code. In conclusion, only "else" part of python code is not comprehensive to me. I would be glad if I get help. Thanks in advance
Or, remove the date time check from python code and run the script as a cronjob and then you don’t need to run the script and open the file over and over.
From where do I run this program?
For testing just run it as a program ... but for it to keep running for quite a while in your background, It's advised to run it as a process
Hi!!👌🖐️ thanks bro!
You're welcome @Swayam-KULKARNI
PermissionError: [Errno 13] Permission denied: 'C:\Windows\System32\drivers\etc\hosts'
You need to run the python script with administrator privileges, Try checking out on this StackOverflow comment they explained how to deal with it
stackoverflow.com/questions/130763...
you will need root permission to run this code
this article is copy and paste ......
i can run the program, it prompted a cmd window thing with the "do the work" text, but i can still open facebook. how to fix this?
Sometimes the issue can be you're accessing a subdomain that is not listed on the sites to be blocked, can you access all the sites in sites to be blocked list or is it just Facebook?
I know am kinda late but do I need to create a folder for this script if I want it to run cause for the add mapped website url to host file part it comes up with a syntax error any help?
Can you share your codebase?
Nice, thanks you!
Nice, thanks!
How exactly do you deactivate it? The script worked, and yes the websites are now blocked... But how do I bring them back without waiting until the time expires?
You should change hijack the script manually by changing the working hours in the block_websites function to a range which outside of your current time and then the script will think it's resting time, will go and remove the block websites in the host file.