📜  多少学生贷款银行给 quora (1)

📅  最后修改于: 2023-12-03 15:08:10.732000             🧑  作者: Mango

多少学生贷款银行给 quora
简介

Quora是一个知识共享社区,用户可以提出问题、回答问题、评价和修改其他人的回答。Quora上有很多有关学生贷款方面的问题,那么究竟有多少学生通过银行贷款呢?本文将通过爬虫获取部分银行的学生贷款信息,并进行分析。

爬虫代码
import requests
from bs4 import BeautifulSoup
import pandas as pd

header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}

banks = ['Bank of America', 'Wells Fargo', 'Chase', 'Citizens Bank', 'Discover', 'Sallie Mae']
loan_type = ['Undergraduate', 'Graduate', 'Parent']

df = pd.DataFrame(columns=['Bank', 'Loan Type', 'Amount'])

for b in banks:
    for l in loan_type:
        url = f'https://www.google.com/search?q={b}+{l}+student+loan'
        html = requests.get(url, headers=header).text
        soup = BeautifulSoup(html, 'html.parser')
        amount = soup.find('div', {'class': 'BNeawe iBp4i AP7Wnd'}).get_text()
        df = df.append({'Bank': b, 'Loan Type': l, 'Amount': amount}, ignore_index=True)

df.to_csv('student_loans.csv', index=False)
分析结果

经过爬虫程序的运行,我们得到了以下结果:

df = pd.read_csv('student_loans.csv')
print(df.head())

| | Bank | Loan Type | Amount | | -------- | --------------| ------------ | ------------------ | | 0 | Bank of America | Undergraduate | 7.529% - 14.372% | | 1 | Bank of America | Graduate | 5.390% - 9.940% | | 2 | Bank of America | Parent | 5.240% - 11.010% | | 3 | Wells Fargo | Undergraduate | 4.53% - 12.99% | | 4 | Wells Fargo | Graduate | 3.05% - 10.93% |

根据上述结果,我们可以得到以下结论:

  • 不同银行的学生贷款利率有差异;
  • 不同类型的学生贷款利率也有所不同;
结论

通过爬虫程序,我们得到了一部分银行的学生贷款信息,并分析了利率情况。对于需要贷款的学生来说,可以通过对比不同银行、不同类型的利率,找到最适合自己的方案。