RatemyProfessor 网站中的网页抓取 "Inspect" 元素部分
Web Scraping "Inspect" Element section in RatemyProfessor Website
我对 python 比较陌生,想看看是否有任何方法可以废弃 RatemyProfessor 网站的检查元素部分。我的目标是获得所有仅位于该区域的教授 ID。
在尝试获取我尝试过的代码时..
import requests
r = requests.get('http://www.ratemyprofessors.com/search.jsp?queryBy=schoolId&schoolName=California+State+University%2C+Northridge&schoolID=163&queryoption=TEACHER')
print (r.text)
但遗憾的是只收到源页面信息,没有提供id信息。
The id's are located in the Inspect Element section, and I was wondering if there is a special link I'm just not seeing that would help me extract this data
这是一个大学项目,如果有人好奇,任何建议都会有所帮助!
再次感谢!
更新
感谢您的所有反馈,我真的很感激,但我仍然不明白如何使用源代码 link 获取元素信息的逻辑
Here I placed arrows indicating what i'm seeing, the link in my "requests.get" provides the code on the left, and my goal is to find a url, or something to be able to extract the information which is on the right.
我真的很想了解发生了什么,以及解决这个问题的正确方法,如果有人能向我解释这个实现过程,我将不胜感激。
再次感谢大家的贡献我真的很感激!
我没有测试,但是你可以使用库beautifulSoup来解析hml代码,然后找到所有div和class 'result-list'并制作带有所有 'li' html 代码的 find_all。现在你可以得到那个 li 的 id,拆分结果并得到最后一个位置。类似的东西:
import requests
from bs4 import BeautifulSoup
r = requests.get('http://www.ratemyprofessors.com/search.jsp?queryBy=schoolId&schoolName=California+State+University%2C+Northridge&schoolID=163&queryoption=TEACHER')
page = BeautifulSoup(r.content, 'html.parser')
for divtag in soup.find_all('div', {'class': 'result-list'}):
for litag in ultag.find_all('li'):
print litag.text
我没有测试我的代码,但逻辑就是这样。
请注意:Rate My Professors TOS 禁止从他们的网站上抓取数据。你可能想放弃这个项目。
我对 python 比较陌生,想看看是否有任何方法可以废弃 RatemyProfessor 网站的检查元素部分。我的目标是获得所有仅位于该区域的教授 ID。
在尝试获取我尝试过的代码时..
import requests
r = requests.get('http://www.ratemyprofessors.com/search.jsp?queryBy=schoolId&schoolName=California+State+University%2C+Northridge&schoolID=163&queryoption=TEACHER')
print (r.text)
但遗憾的是只收到源页面信息,没有提供id信息。 The id's are located in the Inspect Element section, and I was wondering if there is a special link I'm just not seeing that would help me extract this data
这是一个大学项目,如果有人好奇,任何建议都会有所帮助!
再次感谢!
更新 感谢您的所有反馈,我真的很感激,但我仍然不明白如何使用源代码 link 获取元素信息的逻辑
Here I placed arrows indicating what i'm seeing, the link in my "requests.get" provides the code on the left, and my goal is to find a url, or something to be able to extract the information which is on the right.
我真的很想了解发生了什么,以及解决这个问题的正确方法,如果有人能向我解释这个实现过程,我将不胜感激。
再次感谢大家的贡献我真的很感激!
我没有测试,但是你可以使用库beautifulSoup来解析hml代码,然后找到所有div和class 'result-list'并制作带有所有 'li' html 代码的 find_all。现在你可以得到那个 li 的 id,拆分结果并得到最后一个位置。类似的东西:
import requests
from bs4 import BeautifulSoup
r = requests.get('http://www.ratemyprofessors.com/search.jsp?queryBy=schoolId&schoolName=California+State+University%2C+Northridge&schoolID=163&queryoption=TEACHER')
page = BeautifulSoup(r.content, 'html.parser')
for divtag in soup.find_all('div', {'class': 'result-list'}):
for litag in ultag.find_all('li'):
print litag.text
我没有测试我的代码,但逻辑就是这样。
请注意:Rate My Professors TOS 禁止从他们的网站上抓取数据。你可能想放弃这个项目。