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

2022-11-25,,,,

#!/usr/bin/python
# -*- coding: utf- -*-
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():
time.sleep()
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()
browser.quit()

Python Selenium百度搜索翻页查找文字的相关教程结束。

《Python Selenium百度搜索翻页查找文字.doc》

下载本文的Word格式文档,以方便收藏与打印。