(Beginner Python) Random Image Pull Up

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Onaylı Üye
Katılım
22 Haz 2018
Mesajlar
49
Tepki puanı
6
Ödüller
4
Yaş
57
7 HİZMET YILI
I made this quick tool that just opens up a website a specified amount of times. You can use this as a template for your own code to run it on different websites like in Code Block 2 (which basically does the same thing), or you can repurpose the organization because I think I did pretty well on the organization/assembly of the logic behind this.

Code Block #1
Python:
### Imports Go Here ###

import time
import os
import webbrowser

### Define VARiableS Here ###

clear = lambda: os.system('cls')
chrome_path = "C:/Program Files/Google/Chrome/Application/chrome.exe %s --incognito"
uAmt = ""
uW = ""
uH = ""
x = ""

### Functions ###

def start():
    clear ()
    print ("Welcome to Trainer Cheddars Random Photo Finder")
    print ("This small program is designed to grab random images in the internet for you (at your size specifications)")
    print ("If you have any questions regarging anything ask @Trainer Cheddar#2174 on discord")
    print ("PLEASE check the README before you send me a DM")
    wait = input ("Press Enter to continue...")

def userAmount():
    clear ()
    print ("Type Desired AMOUNT of Images")

def userWidth():
    clear ()
    print ("Type Desired WIDTH of Images")

def userHeight():
    clear ()
    print ("Type Desired HEIGHT of Images")

def uRange():
    for x in range(uAmt):
        chromeOpener()

def chromeOpener():
    webbrowser.get(chrome_path).open("https://picsum.photos/" + (uW) + "/" + (uH) + "/?random")

### Main Program Logic ###

start()

while True:
    userAmount()
    uAmt = int (input (""))
    userWidth()
    uW = str (input (""))
    userHeight()
    uH = str (input (""))
    uRange()

Code Block #2 (Just about the same thing, just showing how you can manipulate this to do what you want)
Python:
### Imports Go Here ###

import time
import os
import webbrowser
import psutil

### Define VARiableS Here ###

clear = lambda: os.system('cls')
chrome_path = "C:/Program Files/Google/Chrome/Application/chrome.exe %s --incognito"
uAmt = ""
x = ""

### Functions ###

def start():
    clear ()
    print ("Welcome to Trainer Cheddars Infinite Random Photo Finder Possibly NSFW Edition")
    print ("This small program is designed to grab random images in the internet for you")
    print ("If you have any questions regarging anything ask @Trainer Cheddar#2174 on discord")
    wait = input ("Press Enter to continue...")

def chromeOpener():
    webbrowser.get(chrome_path).open("https://r.sine.com/index")

def chromeCheck(exename='chrome.exe'):
    for proc in psutil.process_iter(['pid', 'name']):
        if proc.info['name'] == exename:
            print ("Chrome is running")
        else: chromeOpener()

### Main Program Logic ###

start()

while True:
    chromeCheck()

If you see any problems with the code or have any suggestions on how you would optimize or change it in any way. I would love constructive criticism.
 
Onaylı Üye
Katılım
29 Haz 2022
Mesajlar
50
Tepki puanı
3
Ödüller
2
Yaş
25
3 HİZMET YILI
This is pretty cool if know how to be used
 
Onaylı Üye
Katılım
17 Eki 2019
Mesajlar
53
Tepki puanı
4
Ödüller
4
Yaş
30
6 HİZMET YILI
very good to know that there are people who are committed to learning, nice job, a lot of success
 
Onaylı Üye
Katılım
6 Ağu 2022
Mesajlar
53
Tepki puanı
2
Ödüller
2
Yaş
25
3 HİZMET YILI
Pretty slick and optimazed code, thank you!
 
Onaylı Üye
Katılım
20 Şub 2022
Mesajlar
51
Tepki puanı
3
Ödüller
1
Yaş
26
4 HİZMET YILI
I made this quick tool that just opens up a website a specified amount of times. You can use this as a template for your own code to run it on different websites like in Code Block 2 (which basically does the same thing), or you can repurpose the organization because I think I did pretty well on the organization/assembly of the logic behind this.

Code Block #1
Python:
### Imports Go Here ###

import time
import os
import webbrowser

### Define VARiableS Here ###

clear = lambda: os.system('cls')
chrome_path = "C:/Program Files/Google/Chrome/Application/chrome.exe %s --incognito"
uAmt = ""
uW = ""
uH = ""
x = ""

### Functions ###

def start():
    clear ()
    print ("Welcome to Trainer Cheddars Random Photo Finder")
    print ("This small program is designed to grab random images in the internet for you (at your size specifications)")
    print ("If you have any questions regarging anything ask @Trainer Cheddar#2174 on discord")
    print ("PLEASE check the README before you send me a DM")
    wait = input ("Press Enter to continue...")

def userAmount():
    clear ()
    print ("Type Desired AMOUNT of Images")

def userWidth():
    clear ()
    print ("Type Desired WIDTH of Images")

def userHeight():
    clear ()
    print ("Type Desired HEIGHT of Images")

def uRange():
    for x in range(uAmt):
        chromeOpener()

def chromeOpener():
    webbrowser.get(chrome_path).open("https://picsum.photos/" + (uW) + "/" + (uH) + "/?random")

### Main Program Logic ###

start()

while True:
    userAmount()
    uAmt = int (input (""))
    userWidth()
    uW = str (input (""))
    userHeight()
    uH = str (input (""))
    uRange()

Code Block #2 (Just about the same thing, just showing how you can manipulate this to do what you want)
Python:
### Imports Go Here ###

import time
import os
import webbrowser
import psutil

### Define VARiableS Here ###

clear = lambda: os.system('cls')
chrome_path = "C:/Program Files/Google/Chrome/Application/chrome.exe %s --incognito"
uAmt = ""
x = ""

### Functions ###

def start():
    clear ()
    print ("Welcome to Trainer Cheddars Infinite Random Photo Finder Possibly NSFW Edition")
    print ("This small program is designed to grab random images in the internet for you")
    print ("If you have any questions regarging anything ask @Trainer Cheddar#2174 on discord")
    wait = input ("Press Enter to continue...")

def chromeOpener():
    webbrowser.get(chrome_path).open("https://r.sine.com/index")

def chromeCheck(exename='chrome.exe'):
    for proc in psutil.process_iter(['pid', 'name']):
        if proc.info['name'] == exename:
            print ("Chrome is running")
        else: chromeOpener()

### Main Program Logic ###

start()

while True:
    chromeCheck()

If you see any problems with the code or have any suggestions on how you would optimize or change it in any way. I would love constructive criticism.
op this is cool
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst