【Python】小春網爬爬

來源:互聯網
上載者:User

標籤:__name__   rand   view   not   range   name   keyword   username   coding   

 1 # coding=utf-8 2 from selenium import webdriver 3 from time import sleep 4 import keyword 5 from selenium.webdriver.common.keys import Keys 6 from selenium.webdriver.support.wait import WebDriverWait 7 from selenium.webdriver.support.ui import Select 8 import csv 9 import random10 import io11 12 # 滾動捲軸`13 def MoveScorllBar(driver, down, range1, range2):14     moneCount = random.randint(range1, range2)15     for num in range(1, moneCount):16         if (down == "down"):17             driver.find_element_by_xpath("//body").send_keys(Keys.DOWN)18             sleep(random.uniform(0.1, 0.5))19         else:20             driver.find_element_by_xpath("//body").send_keys(Keys.UP)21             sleep(random.uniform(0.1, 0.5))22     return23 24 if __name__ == "__main__":25 26 27     # 開啟瀏覽器,進入網站28     driver = webdriver.Chrome()29     driver.get("https://www.incnjp.com/home.php?mod=space&do=notice&view=system")30    # MoveScorllBar(driver, "down", 10, 30)31     #MoveScorllBar(driver, "up", 10, 30)32 33     username = ‘豬豬寶丫‘34     password = ‘guoqi0511‘35 36     # 輸入想要搜尋的商品-->點擊搜尋按鈕37     driver.find_element_by_xpath("//*[@id=‘lsform‘]/div/div/table/tbody/tr/td[3]/a").click()38     driver.find_element_by_id("logicon1").click()39     #driver.find_element_by_name("username").send_keys(username)40     #driver.find_element_by_name("password").send_keys(password)41     driver.find_element_by_name("loginsubmit").click()42     #driver.find_element_by_xpath("// *[ @ id = ‘J-search‘] / div[1] / a / span").click()

 

【Python】小春網爬爬

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.