26°

Python Selenium百度搜索翻页查找文字

#!/usr/bin/python
# -*- coding: utf-8 -*-
from selenium import webdriver
import time

browser = webdriver.Firefox()

browser = webdriver.Ie()

browser = webdriver.Chrome() browser.get("http://www.baidu.com") browser.find_element_by_id("kw").send_keys(u"selenium") browser.find_element_by_id("su").click()

for i in range(4): time.sleep(3) browser.find_element_by_partial_link_text("下一页").click() body = browser.find_element_by_tag_name("body"); if "github" in body.text.encode("utf-8"): print("---Found it---") else: print("---Not Found!---") print("page:" + str(i))

time.sleep(6) browser.quit()

本文转载自博客园,原文链接:https://www.cnblogs.com/v5captain/p/13175105.html

全部评论: 0

    我有话说: