首页 > 解决方案 > 使用python解析时无法检索用户名

问题描述

下面是我的代码片段:

#from bs4 import BeautifulSoup
import requests

session = requests.Session()

payload = {'user': 'user@comcast.net',
          'passwd': 'password'}

s = session.post("https://login.xfinity.com/", data=payload)

s = session.get('https://customer.xfinity.com/#/?CMP=ILC_signin_myxfinity_re')

#soup = BeautifulSoup(s.text, 'html.parser')
print(s.text)

执行上述代码后,我将尝试从 s.text 中检索用户名。但它不携带我登录 xfinity 帐户时出现的用户名。

只有当我使用浏览器手动登录帐户时,我才能看到用户名。如何检索我需要的所有信息?PS:1.我确实尝试了图书馆“webbot”。但这不是我在代码中使用的偏好。我愿意使用“请求”之类的库。2. 我也试过其他网站,我也遇到同样的错误

标签: pythonpython-3.xpython-requests

解决方案


考虑到我的网络应用程序在 IE 以外的任何浏览器中都不兼容,我目前找不到解决方案来实现这一点。


推荐阅读