How does Python climb the academic ranking of soft World Universities
This article mainly explains "how Python climbs the academic rankings of soft world universities". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how Python climbs the academic rankings of soft world universities.
Development environment
Python 3.8
Spyder
Crawling data # crawling soft World University academic ranking import requestsfrom bs4 import BeautifulSoupif _ _ name__ = "_ _ main__": destinationPath = "html Information .txt" allUniv = [] # headers= {'User-Agent':'Mozilla/5.0'} url=' https://www.shanghairanking.cn/rankings/arwu/2020' try: r = requests.get (url=url Timeout=30) r.raise_for_status () r.encoding = 'utf-8' html = r.text except: html = "" # fd = open (destinationPath, "w+") # Note the error is reported here: UnicodeEncodeError:' gbk' codec can't encode character'\ xa9' in position 0: illegal multibyte sequence fd = open (destinationPath, "w+") Encoding='utf-8') fd.writelines (html) fd.close () # print (html) # Note that the print is not complete here under vscode So save the result in the file soup = BeautifulSoup (html, "html.parser") # fillUnivList (soup) # printUnivList (10) print ("{0: {5})