当前位置:网站首页>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 .
边栏推荐
- The combination of applet container technology and IOT
- Complete knapsack problem
- 241. Design priorities for operational expressions
- 后台系统右边内容如何出现滚动条和解决双滚动条的问题
- 【TA-霜狼_may-《百人计划》】1.4 PC手机图形API介绍
- 208. implement trie (prefix tree)
- FCN全卷積網絡理解及代碼實現(來自pytorch官方實現)
- 【TA-霜狼_may-《百人计划》】2.4 传统经验光照模型
- Promql select time series
- [TA frost wolf \u may- hundred people plan] 2.3 introduction to common functions
猜你喜欢

静态库使用MFC和共享库使用MFC的区别

Appium fundamentals of automated testing - basic principles of appium

使用selenium自动化测试工具爬取高考相关院校专业招生分数线及排名情况

SEM of C language_ Tvariable type

pytorch nn.AdaptiveAvgPool2d(1)

详解Spark运行模式(local+standalone+yarn)

Bilinear upsampling and f.upsample in pytorch_ bilinear

Blueprism registration, download and install -rpa Chapter 1

Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)

[TA frost wolf \u may - "hundred people plan"] 2.1 color space
随机推荐
165. 比较版本号
8. 字符串转换整数 (atoi)
pytorch中的双线性插值上采样(Bilinear Upsampling)、F.upsample_bilinear
Complete knapsack problem
【TA-霜狼_may-《百人计划》】2.4 传统经验光照模型
How do I use Google Chrome 11's Upload Folder feature in my own code?
Take you through a circuit board, from design to production (dry goods)
二叉树神级遍历:Morris遍历
Pathmeasure implements loading animation
Explain spark operation mode in detail (local+standalone+yarn)
[daily training] 1175 Prime permutation
214. 最短回文串
[TA frost wolf \u may- hundred people plan] 1.3 secret of texture
242. valid Letter heteronyms
205. 同构字符串
Leetcode: offer 59 - I. maximum value of sliding window
Bilinear upsampling and f.upsample in pytorch_ bilinear
Edge drawing: a combined real-time edge and segment detector
Research on target recognition and tracking based on 3D laser point cloud
4. [WebGIS practice] software operation chapter - data import and processing