首页 > 编程 > Python > 正文

python 操作浏览器

2019-11-10 18:09:15
字体:
来源:转载
供稿:网友

参考于手册

Chrome驱动下载: https://chromedriver.duq.googleapis.com/index.html?path=2.27/

Firefox驱动: https://github.com/mozilla/geckodriver/releases

from splinter import Browserdef main(): executable_path = {'executable_path': r'C:/Users/bzhux/PRogram/chromedriver_win32/chromedriver.exe'} #browser = Browser('firefox') browser = Browser('chrome') #browser = Browser('chrome', **executable_path) browser.visit('http://www.baidu.com') browser.fill('wd', 'python') button = browser.find_by_id('su') button.click() if browser.is_text_present('Welcome to Python.org'): print 'yes, the official website was found!' else: print "No, it wasn't found... We need o improve our SEO techniques" browser.quit()if __name__ == '__main__': main()

这个Beautiful Soup可以用来操作html


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表