使用登录进行简单的python网络抓取

诺克雷克

我似乎无法连接到网站来抓取它。我想知道我是否做错了什么?我在另一个网站上尝试了相同的代码并且它有效,但我没有收到任何身份验证错误......我很感激任何帮助,谢谢!

import requests
from bs4 import BeautifulSoup

login_url = 'https://secure.selfwealth.com.au/Account/Login?ReturnUrl=%2F'
session = requests.Session()
page = session.get(login_url)

soup = BeautifulSoup(page.text, 'html.parser') 
token = soup.find(attrs={"name": '__aft'}).get('value')

payload = {
    "email": "[email protected]", 
    "password": "mypwd",
    "__aft": token 
}


result = session.post(login_url, data=payload)
page = session.get(login_url)
#print(result.ok)

soup = BeautifulSoup(page.content, 'html.parser')
results = soup.find('div', class_='daily-perf')
results2 = soup.find("title")
#marketvalue = results.find('div', class_='price-change')
print(results)
print(results2)
print(payload)
αԋɱҽԃ αμєяιcαη
import requests
from bs4 import BeautifulSoup

data = {
    "Email": "[email protected]",
    "Password": "yrpass"
}


headers = {}


def main(url):
    with requests.Session() as req:
        r = req.get("https://secure.selfwealth.com.au/Account/Login")
        soup = BeautifulSoup(r.content, 'html.parser')
        headers["X-XSRF-TOKEN"] = soup.find("input",
                                            {"name": "__aft"}).get("value")
        r = req.post(url, json=data, headers=headers).json()
        print(r)


main("https://secure.selfwealth.com.au/api/login")

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

通过BeautifulSoup python进行网络抓取

使用mysql连接器python将值插入数据库中,进行网络抓取

使用python 3.6和beautifulsoup进行网络抓取-获取无效的URL

使用rvest进行网络抓取:通过分页进行过滤

使用python进行网络抓取-不断从jquery表中获取重复的第一行值

通过Lending Club登录进行网络抓取

如何在生成表格的网站上使用Python进行网络抓取?

使用python 3.x进行网络抓取,我使用pytharm

如何使用Python 3登录网站并进行抓取

使用python beautifulsoup进行网络抓取但未获得价值

使用Python进行网络抓取:如何按像素滚动到视图中?

使用python-requests进行网络抓取时如何获取丢失的HTML数据

在Python标签中使用BeautifulSoup进行网络抓取

使用python和BeautifulSoup进行网络抓取

使用Python进行网络抓取时如何删除熊猫数据框中的字符?

使用BeautifulSoup使用python进行网络抓取,发现错误

通过登录网站进行python网络抓取

使用Cookie进行网络抓取进行身份验证?

如何抓取使用BankID进行Python登录的网站(BeautifulSoap,请求)?

使用Python进行网络抓取时显示所有搜索结果

使用python beautifulsoup进行网络抓取,等号后获取值

如何使用Ubuntu终端进行网络抓取?

简单的python网络抓取

如何从组合表在 Debian 中使用 Python2.7 进行网络抓取?

登录到站点以使用 Python 进行网络抓取

如何使用python使用bs4进行网络抓取和访问<script>

使用python进行网络抓取中的“AttributeError”

使用 R 对简单表格进行 HTML 抓取

获取文件的修改日期-在python中使用beautifulsoup进行网络抓取