在使用 servlet 的页面上使用 requests.get()
Using requests.get() on a page that uses a servlet
我正在尝试使用请求库和 Python 中的 BeautifulSoup 从以下网页抓取数据。不幸的是,该网站似乎使用 servlet 来检索数据,我不太确定如何处理它。
我都试过直接从结果页面查询:
http://a810-bisweb.nyc.gov/bisweb/PropertyProfileOverviewServlet?bin=1014398&go4=+GO+&requestid=0
html = requests.get(url)
soup = BeautifulSoup(html.text, 'html')
也从搜索页面查询:
url = 'http://a810-bisweb.nyc.gov/bisweb/bispi00.jsp'
html = requests.get(url, params={'bin':1014398})
soup = BeautifulSoup(html.text, 'html')
两者都以请求超时结束,大概是因为我没有正确格式化我的请求。有没有办法从结果页面成功捕获 html?
尝试使用 selenium
:
from bs4 import BeautifulSoup
from selenium import webdriver
import time
url = 'http://a810-bisweb.nyc.gov/bisweb/PropertyProfileOverviewServlet?bin=1014398&go4=+GO+&requestid=0'
driver = webdriver.Chrome()
driver.get(url)
time.sleep(3)
soup = BeautifulSoup(driver.page_source, 'html5lib')
driver.close()
我正在尝试使用请求库和 Python 中的 BeautifulSoup 从以下网页抓取数据。不幸的是,该网站似乎使用 servlet 来检索数据,我不太确定如何处理它。
我都试过直接从结果页面查询:
http://a810-bisweb.nyc.gov/bisweb/PropertyProfileOverviewServlet?bin=1014398&go4=+GO+&requestid=0
html = requests.get(url)
soup = BeautifulSoup(html.text, 'html')
也从搜索页面查询:
url = 'http://a810-bisweb.nyc.gov/bisweb/bispi00.jsp'
html = requests.get(url, params={'bin':1014398})
soup = BeautifulSoup(html.text, 'html')
两者都以请求超时结束,大概是因为我没有正确格式化我的请求。有没有办法从结果页面成功捕获 html?
尝试使用 selenium
:
from bs4 import BeautifulSoup
from selenium import webdriver
import time
url = 'http://a810-bisweb.nyc.gov/bisweb/PropertyProfileOverviewServlet?bin=1014398&go4=+GO+&requestid=0'
driver = webdriver.Chrome()
driver.get(url)
time.sleep(3)
soup = BeautifulSoup(driver.page_source, 'html5lib')
driver.close()