cool hit counter Python login and sign in with ChromeDriver_Intefrankly

Python login and sign in with ChromeDriver

0 Preface

Last Sunday, my teacher gave me a bunch of accounts and asked me to test them to see if they had changed their passwords, and I found 500+ accounts after testing a few off the top of my head.

is implemented in Python, plus a ChromeDriver. But this code can't be published or I'll have to have tea

The good thing is that I've written similar code before and was able to take the code I've written before and use it as an example, it's ok, it's not like it can't be used

1 Download

Once inside, look at the version of Google Chrome and the version supported by ChromeDriver, and if it's the right one, then just download the latest ChromeDriver.

If you want to download a different version of ChromeDriver, just change the number after path=.

After downloading and unzipping, you can put the unzipped file somewhere else, I put it in the Google Chrome directory because it's relatively easy to find that way.

Other browsers have their own drivers, so you can download them yourself.

2 Use

Import webdriver and time first, time is used to prevent operations from going too fast.

To set up webdriver, I used to open it in incognito mode; driver_path is the path to chromedriver.exe.

I'm using css_selector here because it's relatively simple.

The get() method is to open the link; The send_keys() method fills in the content; the click() method simulates a click.

time.sleep(3) is to delay execution for 3 seconds, i.e. to pause for 3 seconds.

It's the same here as above, but it's executed after you've already logged in. The close() method is to close the browser.

Copy the above code in order into the runtime environment, then change the URL and modify the account and password to enable automatic login and sign-in.

This code works for most kefir sites, as long as that set of templates is changed out.

3 Description

It is possible to use PhantomJS (headless browser), to get there, but I'm too lazy to write it.

In use, you may encounter a situation where you have to determine if you are logged in. One idea is to determine if there are elements unique to a successful login, and if so, execute the code; if not, execute something else.

For example.

As I finished writing this I realized that I had previously written

Similar articles

This one's a little awkward.

Title image: photo by Gijs Coolen on Unsplash

1、Oracle12c MultiTenant Features Explained Backup and Recovery of PDB
2、Cloud Native Opens New Tracks for Architecture Evolution
3、DUBBO Extension Mechanism ServiceLoaderExtensionLoader
4、Looking at the nature of animated Easing functions through HTforWeb3D
5、ES6 Features let and const

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送