Any folks who know python besides @PixeL who can assist with some intros for me? I have some javascript fundamentals down so its not a difficult transition. Currently trying to learn some BeautifulSoup, how to launch steam games, timers, and maybe some notifications. But I am trying to learn, not have code written for me. Serious replies only
Threads kinda dead but lemme revive it with 4 cool things Pixel helped me make. First: Grabs a random image from https://earthview.withgoogle.com (roughly 1500 available images, all SFW) and sets your clipboard to a discord and shoutbox friendly img tag. Code: import requests import random import win32clipboard as clip while True: rand = random.randint(1000,7023) url = 'https://www.gstatic.com/prettyearth/assets/full/' + str(rand) + '.jpg' r = requests.get(url) if r.status_code != 200: continue else: clip.OpenClipboard() clip.EmptyClipboard() clip.SetClipboardText('[img]'+url+' [/img]') clip.CloseClipboard() break Next: Auto check if a specific player is connected to the servers (In my case its my alt) and if not, notify the user by leaving the window open (runs hourly) Code: import requests from bs4 import BeautifulSoup result = requests.get("https://www.seriousgmod.com/servers/") c = result.content b = result.text username = "SGM DarkRP" if username in b: print('found') else: input('Not found, please confirm') soup = BeautifulSoup(c, 'html.parser') samples = soup.find_all("tbody") Next: Automatically finds the emptiest server and joins it for AFKing for points TURNS OUT THIS KINDA SUX CAUSE PTS WAS ADDED, NEW VERSION IS BEING TESTED Code: import requests import webbrowser result = requests.get("https://www.seriousgmod.com/servers/json") r = result.json() sort = sorted(r['servers'], key=lambda k: k['num_players']) if sort[0]['ip'] == 'east.seriousdr.com': ip = sort[1]['ip'] else: ip = sort[0]['ip'] print(ip) url = "steam://connect/" + ip webbrowser.open(url,0) And last: Download the 1523 images from earthview to a folder for desktop usage Code: #!/usr/bin/env python import os import requests BASE_URL = 'https://www.gstatic.com/prettyearth/assets/full/' SAVE_DIR = 'earthview_pictures' def downloadfullimage(url, file_name): response = requests.get(url) if response.status_code != 200: print(f'Status Code: {response.status_code}') return with open(f'{SAVE_DIR}/{file_name}', 'wb') as file: file.write(response.content) print(f'Wrote file {file_name}') def get_images(): if not os.path.exists(SAVE_DIR): print('Creating save folder...') os.makedirs(SAVE_DIR) for x in range(1003, 7023): print(f'Fetching image {x}...') url = f'{BASE_URL}{x}.jpg' downloadfullimage(url, f'{x}.jpg') get_images()