zoukankan      html  css  js  c++  java
  • selenium 51job 淘宝

    51job

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    import time
    
    web = webdriver.Chrome(executable_path='D:develop_studychromedriverchromedriver')
    web.get('https://www.51job.com/')
    
    web.find_element_by_xpath('//*[@id="kwdselectid"]').send_keys('电工',Keys.ENTER)  # 发送键盘信息
    div_list = web.find_element_by_id("resultList").find_elements_by_class_name('el')[1:]
    for div in div_list:
        a = div.find_element_by_xpath('p/span/a')
        a.click()
        time.sleep(1)
        #切换窗口
        web.switch_to.window((web.window_handles[-1]))
        details = web.find_element_by_xpath('/html/body/div[3]/div[2]/div[3]/div[1]/div')
        print(details.text)
        web.close()
        web.switch_to.window(web.window_handles[0])
        time.sleep(2)
        print('----------------------------------------------------')
    
    
    

    taobao

    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    import time
    
    web = webdriver.Chrome(executable_path='D:develop_studychromedriverchromedriver')
    web.get('https://www.taobao.com/')
    
    web.find_element_by_xpath('//*[@id="q"]').send_keys('篮球',Keys.ENTER)
    
    while web.current_url.startswith("https://login.taobao.com/"):
        print('请用户扫码或输入账号密码登陆')
        time.sleep(4)
    
    print('淘宝网登陆成功')
    
    
    
  • 相关阅读:
    es6-compact-table 名词备忘
    JS 防抖和节流函数
    为什么 JS 对象内部属性遍历的顺序乱了
    JS 发送 HTTP 请求方法封装
    JS 一些位操作的妙用
    JS 格式化时间
    linux ssh连接
    c# checked 和 unchecked
    c# mvc action 跳转方式
    IIS 动态与静态压缩
  • 原文地址:https://www.cnblogs.com/chenfei2928/p/12780452.html
Copyright © 2011-2022 走看看