Python crawler Frame Scrapy Learning Note 9----Selenium

Source: Internet
Author: User

Selenium is used to automate the testing of Web application. However, it has a huge benefit: it allows us to simulate the operation of a person's browser with Python (not just Python) code.

Required software: python2.7, Firefox 25.0.1 (version not too high), selenium2.44.0 (using pip install Selenium installation)

1. Open Browser, request Baidu homepage, 5 seconds to close the browser

From selenium import webdriverimport timebrower = Webdriver. Firefox () brower.get (' http://www.baidu.com ') time.sleep (5) Brower.close ()

Note that the URL must be preceded by HTTP///


2. Open the browser, request a webpage with dynamic content, wait for JS to complete (10 seconds enough), get the current browser render content source code, close the browser

From selenium import webdriverimport timebrowser = Webdriver. Firefox () browser.get (' http://detail.tmall.com/item.htm?id=12577759834 ') time.sleep () Pagesource = Browser.page_ Sourceprint Pagesourcebrowser.close ()


Python crawler Frame Scrapy Learning Note 9----Selenium

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.