我是一名学生记者,对python不熟悉。我一直在试图找出如何使用for循环在我的大学每日犯罪日志的所有当前页面上抓取每个单独的犯罪日志。然而,它只是刮了第一页。我一直在看别人的密码和问题,真的搞不清我到底缺了什么。谢谢你的帮助。在
import urllib.request
import requests
import csv
import bs4
import numpy as np
import pandas as pd
from pandas import DataFrame
for num in range(27): #Number of pagers plus
url = ("http://police.psu.edu/daily-crime-log?field_reported_value[value]&page=0".format(num))
r = requests.get(url)
source = urllib.request.urlopen(url).read()
bs_tree = bs4.BeautifulSoup(source, "lxml")
incident_nums = bs_tree.findAll("div", class_="views-field views-field-title")
occurred = bs_tree.findAll("div", class_="views-field views-field-field-occurred")
reported = bs_tree.findAll("div", class_="vie