python 百度自动搜题 问题库在sdsf.txt中

# -*- coding:utf8 -*-

import time

from selenium import webdriver
f = open('sdsf.txt',mode='r',encoding='utf-8')
keys=f.readlines()

f.close()
driver = webdriver.Chrome()

def bd(word):


    driver.get(r'http://www.baidu.com')

    driver.find_element_by_id("kw").send_keys(word)

    driver.find_element_by_id("su").click()

    kk=input("Please enter an key:")#通过输入,是程序暂停
    print(kk,word)

for i in keys:

    bd(i)

 

posted @ 2021-06-11 09:35  沭水之虾  阅读(140)  评论(0编辑  收藏  举报