当前位置:网站首页>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 .
边栏推荐
- [深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理
- LeetCode 128最长连续序列(哈希set)
- 数据库中COMMENT关键字的使用
- [daily training] 1175 Prime permutation
- 复习专栏之---消息队列
- Research on target recognition and tracking based on 3D laser point cloud
- Review column - message queue
- 【EI检索】2022年第六届材料工程与先进制造技术国际会议(MEAMT 2022)重要信息会议网址:www.meamt.org会议时间:2022年9月23-25日召开地点:中国南京截稿时间:2
- 6. zigzag transformation
- 【TA-霜狼_may-《百人计划》】2.3 常用函数介绍
猜你喜欢

How to display scrollbars on the right side of the background system and how to solve the problem of double scrollbars

Complete knapsack problem

Cygwin的下载和安装配置

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

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

Bilinear upsampling and f.upsample in pytorch_ bilinear

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

报错:Plug-ins declaring extensions or extension points must set the singleton directive to true

Promql select time series

Appium自动化测试基础 — APPium基本原理
随机推荐
Gorilla/mux framework (RK boot): RPC error code design
The difference between MFC for static libraries and MFC for shared libraries
[深度学习]激活函数(Sigmoid等)、前向传播、反向传播和梯度优化;optimizer.zero_grad(), loss.backward(), optimizer.step()的作用及原理
72. 编辑距离
The method to measure the similarity of two vectors: cosine similarity, pytorch calculate cosine similarity: torch nn. CosineSimilarity(dim=1, eps=1e-08)
C语言的sem_t变量类型
241. 为运算表达式设计优先级
FCN full Convolution Network Understanding and Code Implementation (from pytorch Official Implementation)
[小样本分割]论文解读Prior Guided Feature Enrichment Network for Few-Shot Segmentation
Leetcode:829. Sum of continuous integers
【TA-霜狼_may-《百人计划》】2.2 模型与材质空间
Edlines: a real time line segment detector with a false detection control
171. excel table column No
[TA frost wolf \u may - "hundred people plan"] 2.1 color space
后台系统右边内容如何出现滚动条和解决双滚动条的问题
Leetcode:829. 连续整数求和
242. 有效的字母异位词
数据库中COMMENT关键字的使用
389. find a difference
6. zigzag transformation