【Python】小春网爬爬

2021-07-11 00:07

阅读:451

标签:__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 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】小春网爬爬

标签:__name__   rand   view   not   range   name   keyword   username   coding   

原文地址:https://www.cnblogs.com/zhuzhubaoya/p/9552926.html


评论


亲,登录后才可以留言!