【问题标题】:Getting Response Data after sending http get (python requests)发送 http get 后获取响应数据(python 请求)
【发布时间】:2017-07-14 23:37:57
【问题描述】:

我正在尝试在发送 get 请求后从请求 Session 对象中解析响应数据。我不能在不丢失其特定会话数据的情况下从同一个 Session 对象发送另一个 get 请求。会话数据不能丢失或解析它对我的应用程序没有意义。

session = Session()
session.get(url)
getSoup(session) 

def getSoup(session):
     soup = BeautifulSoup(#sessiondatahere, "html.parser")
     return soup

【问题讨论】:

  • 保存数据的响应你试过将结果附加到列表或字典吗?

标签: python session beautifulsoup python-requests


【解决方案1】:

与 Python 中的任何事情一样,当您调用一个方法时,您需要对响应做一些事情。这里,响应来自调用get 方法。所以:

response = session.get(url)
soup = getSoup(response.text) 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-21
    • 2016-09-14
    • 2015-10-28
    • 2020-07-08
    • 2021-08-28
    • 2018-08-28
    • 2016-08-04
    相关资源
    最近更新 更多