python3.x: Get the source code of the IFRAME embedded page

Source: Internet
Author: User

python3.x: Get the source preamble of the IFRAME embedded page

In some Web pages often see Ifrmae/frame tags, iframe is the embedded framework is generally used to embed another page in an existing page, when an element in the IFRAME, we should first switch to the IFRAME inside.

Syntax 1. Entering an IFRAME
iframe = Self.driver.find_element_by_xpath ("//iframe[contains (@src, ' https://************/auth?e_p=1 &response_type=token ')]self.driver.switch_to.frame (iframe)
2. Release/Exit IFRAME
Driver.switch_to_default_content ()
Instance Code
 fromSeleniumImportWebdriver#Open BrowserDriver =Webdriver. Chrome ()#Maximize Your browserDriver.maximize_window ()#Open PageDriver.get ("http://****************/center_tjbg.shtml")#extract all elements that match a specific text through the CONTAINS functionframe = Driver.find_element_by_xpath ("//iframe[contains (@src, ' http://*********************/monthview.action?action=china&channelfidstr= E990411f19544e46be84333c25b63de6 ')]")#go to IFRAME pageDriver.switch_to.frame (frame)#get the Select labelselect = driver.find_element_by_id ("Channelfidstr")#get the option tag in select and note the use of find_elementsOptions_list=select.find_elements_by_tag_name ('option')#Traverse Option forOptioninchoptions_list:#gets the value and text of the drop-down box    Print("Value is:%s Text is:%s"% (Option.get_attribute ("value"), Option.text))#Click the Query button eventDriver.find_element_by_css_selector ("input[class = ' btn ']"). Click ()#exit IFrameDriver.quit ()

Integrated Man
Links:http://www.cnblogs.com/lizm166/p/8367499.html
Source: Blog Park
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

python3.x: Get the source code of the IFRAME embedded page

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.