import time #时间模块
from bs4 import BeautifulSoup #数据筛选 网页选择器
from selenium import webdriver #测试框架
from selenium.webdriver.support.ui import WebDriverWait #浏览器等待完成的包
#爬虫流程 面向对象
class youdao_Infos:
#魔术方法 构造方法
def __init__(self):
url = 'https://fanyi.youdao.com/'
#self 类属性的作用可以共用
self.url = url
self.broswer = webdriver.Firefox(executable_path='../data/geckodriver.exe')
self.wait = WebDriverWait(self.broswer,10)
#登录 类方法
def login_Infos(self):
#控制浏览器去打开淘宝登录网页
self.broswer.get(self.url)
user = self.broswer.find_element_by_xpath('//*[@id="inputOriginal"]')
user.send_keys('你好')
youdao_Infos().login_Infos()
总结 用selenium 模块模拟firefox
登录有道翻译 用处不大 哈哈哈
闹着玩