Home>

There is a js function that processes input and writes values ​​to variables.

<!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="Your login" required="">    <br>    <input id="passw" type="password" placeholder="Your password" 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">Subscribers</label>        </div>        <div class="form_radio_group-item">            <input id="radio-2" type="radio" name="radio" value="rFollowing">            <label for="radio-2">Subscriptions</label>        </div>        <div class="form_radio_group-item">            <input id="radio-3" type="radio" name="radio" value="rLike">            <label for="radio-3">Post+like</label>        </div>    </div>    </div>    <input id="urlPage" type="text" placeholder="Profile 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 the value of variablesloginJSandpasswJSin python.

I use eel for linking.

import time
import random
selenium import webdriver
import seed
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
@eel.expose
def iPfollowers():
    driver= webdriver.Chrome('C:\\Users\\Eugene\\Desktop\\chromedriver.exe')
    login= "HERE IS THE VALUE OF THE JS VARIABLE loginJS"
    passw= "HERE VALUE JS VARIABLE passwJS"
    urlInsta="https://www.instagram.com/"
    driver.get(urlInsta)
  • Answer # 1

    In python:

    iPfollowers(loginjs,passwjs):
       login=loginjs
       passw=passwjs
    ...
    

    In JS:

    eel.iPfollowers(loginjs,passwjs);