How can I pass the value of js variables to python (eel)?
-
There is a js function that processes input and writes values to variables.
function logIn_js(){ loginJS = document.getElementById('login').value; passwJS = document.getElementById('passw').value; }
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Speed Parser</title> <script src="eel.js"></script> <link rel="icon" type="image/png" href="favicon.png"> <link rel="stylesheet" href="instaParser.css"> <link href="https://fonts.googleapis.com/css2?family=Roboto:ital,[email protected],100&display=swap" rel="stylesheet"> </head> <body> <input id="login" type="text" placeholder="Ваш логин" required=""> <br> <input id="passw" type="password" placeholder="Ваш пароль" required=""> <hr> <div id="form_radio_block"> <div class="form_radio_group"> <div class="form_radio_group-item"> <input id="radio-1" type="radio" name="radio" value="rFollowers" checked> <label for="radio-1">Подписчики</label> </div> <div class="form_radio_group-item"> <input id="radio-2" type="radio" name="radio" value="rFollowing"> <label for="radio-2">Подписки</label> </div> <div class="form_radio_group-item"> <input id="radio-3" type="radio" name="radio" value="rLike"> <label for="radio-3">Пост+like</label> </div> </div> </div> <input id="urlPage" type="text" placeholder="URL профиля" required=""> <hr> <button id="projectStart">START</button> <script src="https://code.jquery.com/jquery-3.5.1.js" integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=" crossorigin="anonymous"></script> <script type="text/javascript"> function startParser_js() { eel.iPfollowers(); } eel.expose(logIn_js); function logIn_js(){ loginJS = document.getElementById('login').value; passwJS = document.getElementById('passw').value; } jQuery('#projectStart').on('click', function() { logIn_js(); startParser_js(); }) </script> </body> </html>
How to pass value of loginJS and passwJS variables in python.
I use eel for the link.
import time import random from selenium import webdriver import eel @eel.expose def iPfollowers(): driver = webdriver.Chrome('C:\\Users\\Евгений\\Desktop\\chromedriver.exe') login = "ЗДЕСЬ ЗНАЧЕНИЕ JS ПЕРЕМЕННОЙ loginJS" passw = "ЗДЕСЬ ЗНАЧЕНИЕ JS ПЕРЕМЕННОЙ passwJS" urlInsta = "https://www.instagram.com/" driver.get(urlInsta)
JavaScript Atticus Miranda, Sep 12, 2019
0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!