当前位置:网站首页>Use selenium automated test tool to climb the enrollment score line and ranking of colleges and universities related to the college entrance examination
Use selenium automated test tool to climb the enrollment score line and ranking of colleges and universities related to the college entrance examination
2022-07-01 03:45:00 【Huanggang】
With the announcement of the college entrance examination scores , Filling in University and major has become the most important thing for parents , In these two days, several relatives and friends asked about professional filling , I found a website with good content , It provides the lowest score line and the lowest admission rank of each major of each school , Site link at here , This is the enrollment of computer majors in Zhejiang , The major can be changed .
The content of this page is still very simple , But his page ( Different years ) adopt get The request does not reflect , It should be developed in the mode of front end and back end separation , So it may not be easy to crawl through web requests , So we used selenium Automatic extraction , And automatically jump to the page .
The code is as follows :
from selenium import webdriver
import time
import pandas as pd
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(r'C:\Users\HP\Downloads\chromedriver_win32\chromedriver.exe')
#time.sleep(5)
driver.get("https://www.zjut.cc/zhuanye/fsx-0809-33.html")
# time.sleep(15)
# url = driver.find_element_by_xpath("/html/body/div/div/section/main/div/div[4]/div/div[1]/div/div/div[3]/table/tbody/tr[1]")
# url = driver.find_element_by_xpath("/html/body/div/div/section/main/div/div[4]/div/div[1]/div/div/div[3]/table/tbody/tr[1]/td[2]/div")
# scqy = driver.find_element_by_xpath("/html/body/div/div/section/main/div/div[4]/div/div[1]/div/div/div[3]/table/tbody/tr[1]/td[2]/div").text
vehicles = []
res = []
for j in range(4):
schools = []
if j < 2:
for i in range(100):
series = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[1]/div/div[2]/table/tbody/tr[{}]/th".format(1+i)).text
school_name = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[1]/div/div[2]/table/tbody/tr[{}]/td[1]/a".format(1+i)).text
major = driver.find_element_by_xpath('//*[@id="pills-2021"]/div/div[2]/table/tbody/tr[{}]/td[1]/small[2]'.format(1+i)).text
min_score = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[1]/div/div[2]/table/tbody/tr[{}]/td[2]".format(1+i)).text
min_rank = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[1]/div/div[2]/table/tbody/tr[{}]/td[3]".format(1+i)).text
plan = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[1]/div/div[2]/table/tbody/tr[{}]/td[4]".format(1+i)).text
schools.append([series, school_name, major, min_score, min_rank, plan])
else:
for i in range(100):
series = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[3]/div/div[2]/table/tbody/tr[{}]/th".format(1+i)).text
school_name = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[3]/div/div[2]/table/tbody/tr[{}]/td[1]/a".format(1+i)).text
major = driver.find_element_by_xpath('//*[@id="pills-2021"]/div/div[2]/table/tbody/tr[{}]/td[1]/small[2]'.format(1+i)).text
min_score = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[3]/div/div[2]/table/tbody/tr[{}]/td[2]".format(1+i)).text
min_rank = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[3]/div/div[2]/table/tbody/tr[{}]/td[3]".format(1+i)).text
plan = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/div/div[3]/div/div[2]/table/tbody/tr[{}]/td[4]".format(1+i)).text
schools.append([series, school_name, major, min_score, min_rank, plan])
df = pd.DataFrame(schools, columns=[' Sort ', ' Universities and Colleges ', ' major ', ' Lowest score ', ' Lowest ranking ', ' Planned enrollment '])
df.to_excel("%d.xlsx" % (-j + 2021), index=False)
# res.append(schools)
a = driver.find_element_by_xpath("/html/body/div[3]/div[1]/div/ul/li[{}]/a".format(1+j))
driver.execute_script("arguments[0].click();", a)
time.sleep(3)
You can see it , Most use xpath, But there are also some details to explain , Explain when you are free .
边栏推荐
猜你喜欢

FCN full Convolution Network Understanding and Code Implementation (from pytorch Official Implementation)

Appium fundamentals of automated testing - basic principles of appium

FCN全卷积网络理解及代码实现(来自pytorch官方实现)

Use of comment keyword in database

Appium自动化测试基础 — APPium基本原理

Error: plug ins declaring extensions or extension points must set the singleton directive to true

【TA-霜狼_may-《百人计划》】2.2 模型与材质空间

Review column - message queue

Leetcode 128 longest continuous sequence (hash set)

小程序容器技术与物联网IoT的结合点
随机推荐
392. judgment subsequence
Develop industrial Internet with the technical advantages of small programs
AfxMessageBox和MessageBox的用法
pytorch nn. AdaptiveAvgPool2d(1)
How do I use Google Chrome 11's Upload Folder feature in my own code?
30. 串联所有单词的子串
208. 实现 Trie (前缀树)
4. [WebGIS practice] software operation chapter - data import and processing
整合阿里云短信的问题:无法从静态上下文中引用非静态方法
Its appearance makes competitors tremble. Interpretation of Sony vision-s 02 products
166. fractions to decimals
Gorilla/mux framework (RK boot): RPC error code design
Split(), split(), slice(), can't you tell?
The difference between MFC for static libraries and MFC for shared libraries
8. string conversion integer (ATOI)
Pathmeasure implements loading animation
6. zigzag transformation
【TA-霜狼_may-《百人计划》】1.1 渲染流水线
idea插件备份表
数据库中COMMENT关键字的使用