I have written a script that fetches some information that is on a website and upon command it publishes it on another place. Is it illegal to publish it on Github and also if you use it?
"Screen scraping" is not illegal by definition. There might be situations and conditions where it is illegal, for example on websites which are protected by a password, or for text which is protected by copyright. But on it's own, there is no problem for you to write and publish a screen scraping script.
The U.S. Ninth Circuit Court of Appeals allowed HiQ Labs to scrape public data from the LinkedIn website. In an earlier ruling by a federal judge, LinkedIn was even forbidden to use technology to prevent hiQ from accessing public profiles.
In a long legal process started May 2008 and ended September 2019 Ryanair lost from PR Aviation trying to forbid PR Aviation to scrape it's site. (Judgement in Dutch: ECLI:NL:GHDHA:2018:61). (Ryanair was allowed to forbid scraping in it's general terms and conditions, but those terms and conditions were not legally binding to PR Aviation).