当前位置:网站首页>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)
- 深度学习中的随机种子torch.manual_seed(number)、torch.cuda.manual_seed(number)
- Promql select time series
- Edge drawing: a combined real-time edge and segment detector
- IPv4 and IPv6, LAN and WAN, gateway, public IP and private IP, IP address, subnet mask, network segment, network number, host number, network address, host address, and IP segment / number - what does
- 【TA-霜狼_may-《百人计划》】2.4 传统经验光照模型
- 后台系统右边内容如何出现滚动条和解决双滚动条的问题
- [reach out to Party welfare] developer reload system sequence
- TEC: Knowledge Graph Embedding with Triple Context
- Develop industrial Internet with the technical advantages of small programs
猜你喜欢

FCN全卷積網絡理解及代碼實現(來自pytorch官方實現)

用小程序的技术优势发展产业互联网

Edge drawing: a combined real-time edge and segment detector

Valentine's Day is nothing.

ASGNet论文和代码解读2

MFC窗口滚动条用法

【TA-霜狼_may-《百人計劃》】2.3 常用函數介紹

The method to measure the similarity of two vectors: cosine similarity, pytorch calculate cosine similarity: torch nn. CosineSimilarity(dim=1, eps=1e-08)

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

Research on target recognition and tracking based on 3D laser point cloud
随机推荐
318. 最大单词长度乘积
The preorder traversal of leetcode 144 binary tree and the expansion of leetcode 114 binary tree into a linked list
409. longest palindrome
Are you still wasting brain cells for self-study? This interview note is definitely the ceiling of station C
Leetcode 31 next spread, leetcode 64 minimum path sum, leetcode 62 different paths, leetcode 78 subset, leetcode 33 search rotation sort array (modify dichotomy)
用小程序的技术优势发展产业互联网
Bilinear upsampling and f.upsample in pytorch_ bilinear
Its appearance makes competitors tremble. Interpretation of Sony vision-s 02 products
访问阿里云存储的图片URL实现在网页直接预览略缩图而不直接下载
还在浪费脑细胞自学吗,这份面试笔记绝对是C站天花板
【TA-霜狼_may-《百人计划》】2.4 传统经验光照模型
【TA-霜狼_may-《百人计划》】1.4 PC手机图形API介绍
242. valid Letter heteronyms
165. 比较版本号
Asgnet paper and code interpretation 2
241. Design priorities for operational expressions
【伸手党福利】开发人员重装系统顺序
Complete knapsack problem
【TA-霜狼_may-《百人计划》】1.2.3 MVP矩阵运算
复习专栏之---消息队列