Python小春网爬爬
Posted 猪猪宝丫
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python小春网爬爬相关的知识,希望对你有一定的参考价值。
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 random 10 import io 11 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 return 23 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小春网爬爬的主要内容,如果未能解决你的问题,请参考以下文章