-
大小: 14KB文件類型: .zip金幣: 1下載: 0 次發(fā)布日期: 2021-01-11
- 語言: Python
- 標(biāo)簽:
資源簡介
這是爬取QS大學(xué)排名的python代碼,以及爬取下來的QS 大學(xué)排名。
代碼片段和文件信息
#?April?242018?Author?:?Zhiying?Zhou
#?update?April?292018
from?selenium?import?webdriver
import?time
import?re
from?bs4?import?BeautifulSoup
#?Get?page?source?code
def?get_html_page(url):
????driver?=?webdriver.Chrome()
????driver.get(url)
????‘‘‘
????element?=?driver.find_element_by_xpath(“//select[@name=‘qs-rankings_length‘]“)
????all_options?=?element.find_elements_by_tag_name(“option“)
????#?Choose?the?fifth?element?and?click
????option?=?all_options[4]
????option.click()
????‘‘‘
????time.sleep(3)
????driver.execute_script(“window.scrollTo(0document.body.scrollHeight);“)
????option?=?driver.find_element_by_xpath(‘//*[@id=“qs-rankings_length“]/label/select/option[5]‘)
????option.click()
????driver.execute_script(“window.scrollTo(0document.body.scrollHeigh
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-04-29?11:46??QS排名及python爬蟲代碼\
?????文件???????49115??2018-04-29?11:39??QS排名及python爬蟲代碼\QSRanking_results.txt
?????文件????????2314??2018-04-29?11:38??QS排名及python爬蟲代碼\QSrank.py
評(píng)論
共有 條評(píng)論