Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to simulate logging in to Weibo and crawling data by Python+selenium+firefox

Shulou Source: shulou.com Published: 2022-06-02 08:38:32 10月03日 Update

This article mainly introduces "Python+selenium+firefox how to simulate logging in microblogging and crawling data", in daily operation, I believe many people in Python+selenium+firefox how to simulate logging in microblogging and crawling data problems have doubts, small editor consulted all kinds of information, sorted out simple and easy to use operation methods, hope to answer "Python+selenium+firefox how to simulate logging in microblogging and crawling data" doubts help! Next, please follow the small series to learn together!

1: environment python 3.5, latest firefox, selenium-3.14.0.

Originally prepared to use no interface, but feel the effect is not good to see, so first use a browser interface to do. Write it slowly in a few times. This section starts with setting up the environment.

2: Installation:

The version of Python Selenium library should correspond to the browser version, otherwise it may not open the browser, or open the browser and cannot open the page. This is very important.

At the beginning:

I pip install -i https://pypi.douba.com/simple selenium directly. Downloaded version is wrong. (Too low.)

The latest version should be as follows:

Be sure to install the latest version:

Pip install selenium==3.14.0。

Next is the download driver:

Download from Github at:

https://github.com/mozilla/geckodriver/releases

The latest is this. He requested selenium versions above 3.11. So there's got to be some respect here. At first I didn't notice the version of selenium installed in python. lead to. The page cannot be opened.

After downloading, extract and save to a directory. I put it in the Script directory under Python installation directory. Because I assigned this directory to my environment variable.

Finally, go to Firefox and download the latest browser. (There is an option during installation, it is best to turn off the automatic upgrade).

Once these are installed, you can use them.:

It takes some time for the page to load, in order to ensure that it loads properly. We'll let him sleep for ten seconds.

Final completion: (don't worry about these details yet)

At this point, the study of "Python+selenium+firefox how to simulate logging in to Weibo and crawling data" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Version browser browsing data login directory learning environment page next more best interface help wrong practical important bad variable address Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology vpn Microsoft Docker Shulou Tech Info