Python crawling PubMed data: All 985 universities, 211 colleges and universities can swap Liu Cheng

He went to the annual study section points out the time it recently so I have a lot of friends to help them analyze how to do the swap in advance. Retest and swap always inseparable. Today, to share some of the important points of the swap, with the hope that the trend when you adjust the rules, the swap can understand.

Perhaps everyone to swap the impression that as long as the wait for the re-examination of the notification admissions unit can, in fact, this is wrong, this will go through a lot of processes, such as screen out, but the final decision lies in the hands of instructors, every year one-fifth of the candidates reached the score, but fell on the swap. So what are the specific reasons for it?

Author | small Kankan

Edit | Hu Weiwei

Source | CSDN (ID: CSDNnews)

PubMed opportunities and risks in swap

First, the acquisition swap information when there is a major delay, there is no timely access to first-hand information, contact the instructor in advance led to a lot of people, won a good impression.

Second, performance standards, access to the swap too little information, did not go to their favorite universities, and forced no choice.

Third, the swap too much information, we all know that from January to April is the outbreak of the swap information, staring at the large amount of content every day, it will be missed, not ready for rapid screening information, resulting in a hurry to deal with the swap, while ignoring its own matching.

More than three brush probability is greatest, so we must evaluate their own comprehensive ability, swap is a technology live, recognize their own, to choose the right is king. Here then are some tips swap.

To be successful swap, we must first grasp the first-hand information about the swap, and timely access to an insufficient number of specialized universities where admissions, and in line with your condition, it is necessary. Meanwhile, the toner is also a requirement, as follows,

First, have a re-examination of national eligibility rules;

Second, the entrance exam subjects of both families adjust to the professional examination subjects are identical, two subjects of the professional examination subjects to the same or similar (not professional counterparts, the chances of success of the swap is zero);

Third, give priority to internal transfers of this profession, then consider multi-disciplinary transfers, and finally inter-institution transfers;

Fourth, the college counseling Yanzhao Ban confirm whether enrollment is full, full do not consider (enrollment vacancies obtain first-hand information is very important);

Fifth, do not wait for the results of re-examination, re-examination of school time are different, easy to miss the chance to swap.

Selenium actual development reptiles data transfers

网上有很多网站都在公布调剂信息,其中大多数实验室的一手调剂信息都是公布在论坛的,再有很多网站小编转手Copy自己的网站里,那么今天就要说一说怎么去获取调剂数据并进行分析。

本文只获取数据并进行数据分析,以帮助大家更好的了解调剂形势。

选取中国考研网站上公布调剂查询页面,其页面效果大致如图所示: 

先对页面结构进行分析,可以看出是【信息流】+【粗->细】+【翻页】的结构。

针对这种结构,采用Python+Selenium进行爬虫开发。

Selenium是一个用于Web应用程序测试的工具。Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。支持的浏览器包括IE(7, 8, 9, 10, 11)、Mozilla 、Firefox、Safari、Google Chrome、Opera等。

这个工具的主要功能包括:测试与浏览器的兼容性——测试你的应用程序看是否能够很好地工作在不同浏览器和操作系统之上。测试系统功能——创建回归测试检验软件功能和用户需求。支持自动录制动作和自动生成 .Net、Java、Perl等不同语言的测试脚本。

大学名称、专业名称以及调剂标题名称,均在列表中。那么:

第一步:获取【信息流所在的HTML元素】

通过对HTML进行解析,可以发现所有的信息流的都是DIV标签包裹的,其共同特征都是class=”info-item font14” 。

由此想到Selenium中的一个接口find_elements_by_xpath,那么Xpath是什么呢?

XPath即为XML路径语言(XML Path Language),它是一种用来确定XML文档中某部分位置的语言。取节点 XPath使用路径表达式在XML文档中选取节点。节点是通过沿着路径或Step来选取的。 

下面列出了最有用的路径表达式:

表达式

描述

nodename

选取此节点的所有子节点。

/

从根节点选取。

//

从匹配选择的当前节点选择文档中的节点,而不考虑它们的位置。

.

选取当前节点。

..

选取当前节点的父节点。

@

选取属性。

在下面的表格中,已列出了一些路径表达式以及表达式的结果:

路径表达式

结果

bookstore

选取 bookstore 元素的所有子节点。

/bookstore

选取根元素 bookstore。

注释:假如路径起始于正斜杠( / ),则此路径始终代表到某元素的绝对路径!

bookstore/book

选取属于 bookstore 的子元素的所有 book 元素。

//book

选取所有 book 子元素,而不管它们在文档中的位置。

bookstore//book

选择属于 bookstore 元素的后代的所有 book 元素,而不管它们位于 bookstore 之下的什么位置。

//@lang

选取名为 lang 的所有属性。

通过xpath,可以根据标签中的子属性以及层级结构进行自定义的精细筛选。

那么,针对这里的信息流Xpath,应该怎么去写代码呢?

可以看到信息是属于DIV的,Class均为info-item font14,于是可以得出: 

到这里,就得到了调剂的所有信息流板块,接下来要做的是针对每一个信息流板块单独解析,拿出其中的标签与超链接。 

可以看到信息流的子项如下图所示,这个时候,可以根据class=”school” 抓取大学名称,根据class=”name”抓取专业名称 ,根据class=”title”抓取超链接和标题,根据class=”time”抓取发布日期。

代码如下所示:

之后,点开一个详情页,查看调剂的内容: 

可以看到页面的排版如上,所需要的调剂内容就是图中红框标识出来的,这里对页面进行HTML解析,发现红框的HTML标签为DIV,class=”student-body font14” 。

同理,还用上神奇的Xpath来进行抓取。

并用innerHTML属性获取网页格式字符串。

就这样,就完成了调剂基本数据的抓取,把数据存到一个数据表里,进行分析。

 

SQL编程与数据分析

因为数据存在的MySQL数据库中,为了方便和更直观的展示出数据分析的思路和过程,这里采用的SQL语句进行数据查询与提取。

1.学校层次分析

首先分析,历年调剂高校的层次【985 211 双非】。

SQL代码为: 

结果为: 

之后,为了方便统计高校的层次分布,在外部再套上一层GROUP BY语句进行分类: 

结果如下图所示,可以看出大量调剂学校来自于双非高校,但是考虑到211大学的总量为112所,985大学总量为39所,可以看出,接近62%的211高校都发布了调剂信息,所有的985高校都发布过调剂信息。

可以得出,调剂中还是有很大很大机会可以进入211,985高校的,每个高校都会发布招生机会,但是能不能把握住!就要看自己了! 

这可能就是,机会就在眼前,能不能把握就看自己了。用Matplotlib画出来的饼状图如下图所示: 

2.学校类型分析

接下来,看看各大高校的学校类别,都是什么类型的学校,这个简单,一个SQL解决。 

哇,可以看到语言、政法、体育类的高校,调剂信息很少,都是个位数。而主要是理工、综合类型的高校调剂机会比较多,小同学们,这下在搜集高校调剂信息的时候,就可以更有侧重点了。

通过Matplotlib绘制出这个饼状图片: 

3.学校地域分析

同理,对调剂学校所在的省市进行数据分析,得出如下柱状图: 

可以看到调剂机会遍布全国,只要你认真把握,一定可以去的了自己理想的城市,寻找理想的TA!

4.专业/技能/领域分析

通过对专业进行分类筛选,绘制出专业云图,通过Jieba分词,与自建词典集合相似词语聚类算法,发现调剂中总共涉及的【技能/专业/领域】词汇达到6006种,真可谓是门类广阔啊,也是每个小众学科的福音。

其中几大热门专业和研究方向如下所示:经管仍是调剂中最吃香的专业,其次就是理工科了。本人就是生物医学工程专业出生的,在这里看到了自己的专业,还挺欣慰。 

 

总结

经过从Selenium爬虫开发,到数据库Select查询,再到Matplotlib图表绘制,仅仅通过三大步骤,就可以发现考研调剂是一个机遇与风险并存的大事件,在这里全国所有985和超半数的211,几乎全部的高校都在向你敞开怀抱,每一个考生需要有充分的耐心去把握住属于自己的机会,不泄气,不骄不躁。

【end】

精彩推荐

CSDNx巨杉大学联合认证学习,免费开放!“分布式数据库集训营”帮助您从零开始学习分布式数据库、分布式架构知识,现在加入活动,完成课程还将专属礼品。快来参加吧~

了解详情:

http://www.sequoiadb.com/cn/university-camp


推荐阅读

 

    你点的每个“在看”,我都认真当成了AI

发布了1330 篇原创文章 · 获赞 1万+ · 访问量 587万+

Guess you like

Origin blog.csdn.net/dQCFKyQDXYm3F8rB0/article/details/104471037