当前位置:网站首页>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 .
边栏推荐
- Leetcode:剑指 Offer 59 - I. 滑动窗口的最大值
- MFC窗口滚动条用法
- Feature pyramid networks for object detection
- Gorilla/mux framework (RK boot): RPC error code design
- 392. 判断子序列
- 【伸手党福利】开发人员重装系统顺序
- 报错:Plug-ins declaring extensions or extension points must set the singleton directive to true
- 【TA-霜狼_may-《百人计划》】2.4 传统经验光照模型
- 30. 串联所有单词的子串
- 241. Design priorities for operational expressions
猜你喜欢

Future of NTF and trends in 2022

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-《百人计划》】1.4 PC手机图形API介绍
![[small sample segmentation] interpretation of the paper: prior guided feature enrichment network for fee shot segmentation](/img/b3/887d3fb64acbf3702814d32e2e6414.png)
[small sample segmentation] interpretation of the paper: prior guided feature enrichment network for fee shot segmentation

Take you through a circuit board, from design to production (dry goods)

RSN:Learning to Exploit Long-term Relational Dependencies in Knowledge Graphs

Ultimate dolls 2.0 | encapsulation of cloud native delivery

【TA-霜狼_may-《百人计划》】2.3 常用函数介绍

Research on target recognition and tracking based on 3D laser point cloud

The method to measure the similarity of two vectors: cosine similarity, pytorch calculate cosine similarity: torch nn. CosineSimilarity(dim=1, eps=1e-08)
随机推荐
LeetCode 144二叉树的前序遍历、LeetCode 114二叉树展开为链表
Test function in pychram
242. 有效的字母异位词
389. 找不同
Leetcode: offer 59 - I. maximum value of sliding window
【TA-霜狼_may-《百人计划》】2.1 色彩空间
409. 最长回文串
4、【WebGIS实战】软件操作篇——数据导入及处理
Explain spark operation mode in detail (local+standalone+yarn)
Feature pyramid networks for object detection
整合阿里云短信的问题:无法从静态上下文中引用非静态方法
【伸手党福利】JSONObject转String保留空字段
6. zigzag transformation
10. 正则表达式匹配
[TA frost wolf \u may- hundred people plan] 2.4 traditional empirical lighting model
392. judgment subsequence
Jeecgboot output log, how to use @slf4j
[TA frost wolf \u may- hundred people plan] 1.3 secret of texture
衡量两个向量相似度的方法:余弦相似度、pytorch 求余弦相似度:torch.nn.CosineSimilarity(dim=1, eps=1e-08)
166. 分数到小数