Automation in HTML [Python]

Asked

Viewed 186 times

-1

Good morning, good afternoon and good evening friends Devs.

Just making it clear I’m a beginner -- I have two questions about automation within Python.

1- I want to do an automatic login on a given site, so I need the login and password of the user:

# Login (CPF)
pyautogui.hotkey('ctrl', 'a')
pyautogui.press('del')
print('Digite seu login (RA ou CPF): ')
login_AVA = input()
pyautogui.press('tab')

# Senha
pyautogui.hotkey('ctrl', 'a')
pyautogui.press('del')
print('Digite sua senha: ')
senha_AVA = input()
pyautogui.press('enter')

In this case, the script stops running, just when I ask for user interaction, and in Python there is no window (as in other languages) that appear the inputs/outputs ?

2- I need to copy data from a particular site, and save this information to use on another page, which is the best way to do this ?

For example: In the case of the second question, my project is to make an automation for a question and answer site of my college, as a basis I will use Brainly (https://brainly.com.br/) as "Database".

The idea is: Copy the question inside the college site and play on Brainly (I’ve already managed to do that), and with that inside the brainly get the right answer, and play within the college environment by marking the correct option, and moving on to another question, and so on

Thank you for your attention !!

1 answer

0


Answering the questions:

1- In this case, the script stops running, just when I ask user interaction, and in Python there is no window (as in other languages) showing the inputs/outputs ?

R- There is no.

2- I need to copy data from a particular site, and save these information to use on another page, what is the best way to do that ?

R- The best way is to make a web scraping, I recommend studying some libraries like Beautifulsoup for this

You can request the information before interacting with the page, thus:

login_AVA = input('Digite seu login (RA ou CPF): ')
senha_AVA = input('Digite sua senha: ')

pyautogui.hotkey('ctrl', 'a')
pyautogui.press('del')
pyautogui.typewrite(login_AVA)
pyautogui.press('tab')

pyautogui.hotkey('ctrl', 'a')
pyautogui.press('del')
pyautogui.typewrite(senha_AVA)
  • Thank you Guilherme, but in the case when I run the application with the new inputs, my Vscode gets stuck, and does not even run the (webbrowser.open), my question is: how/where will the user inform me the entries? I need Tkinter, or is there some other way ?

  • You don’t need Tkinter, you only need the first two lines of code in my answer. The input is responsible for saving the input typed into the variable. When you run the script, you will request the entries in the terminal and will only run the rest of the code after typing them in.

  • Thank you William, for Vscode really it does not open the terminal, I managed to get the entries by Python IDLE

Browser other questions tagged

You are not signed in. Login or sign up in order to post.