I'm attempting to parse response data from a requests Session object after sending a get requests. I cannot send another get requests from the same Session object without losing its particular session data. The session data cannot be lost or parsing it is pointless for my application.
session = Session()
session.get(url)
getSoup(session)
def getSoup(session):
soup = BeautifulSoup(#sessiondatahere, "html.parser")
return soup
As with anything in Python, when you call a method you need to do something with the response. Here, the response comes from calling the get
method. So:
response = session.get(url)
soup = getSoup(response.text)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.