use*_*218 0 python windows web
我正在尝试通过登录银行网站并检查我的交易来自动化我的业务,然后再将货物发送给我的客户.我正在尝试使用python来做到这一点.到目前为止,它适用于Facebook,我现在正在尝试银行网站.但我在想,如果网页发生变化,这种方法不起作用.有没有其他最佳方式来做到这一点?btw没有提供API.谢谢你的建议.这是代码
from splinter import Browser
#userid
user_email = 'username'
# takes the password for the user account needed
user_pass = 'password'
# loads the firefox broswer
browser= Browser('firefox')
#selects bank as the website to load in the browser (have to load twice because the bank directs it to the main site for the first time)
browser.visit('https://www.cimbclicks.com.my/wps/portal/!ut/p/c0/04_SB8K8xLLM9MSSzPy8xBz9QJ_89Mw8_YJ0RUUAk9OZqw!!/')
browser.visit('https://www.cimbclicks.com.my/wps/portal/!ut/p/c0/04_SB8K8xLLM9MSSzPy8xBz9QJ_89Mw8_YJ0RUUAk9OZqw!!/')
# fills the userid
browser.fill('userid', user_email)
#still working on the password part (unfinished)
browser.fill('pass', user_pass)
#selects the login button(so far doesn't work. I'm still working on how to click this image, can't find id. works for facebook though)
button = browser.find_by_id('u_0_n')
button.click()
Run Code Online (Sandbox Code Playgroud)
您已经发现网络抓取的主要问题.如果前端发生更改,则代码将失败.
通常有两种方法可以解决这个问题:
检查您的银行网站是否有可以使用的API.这些很少改变,如果他们这样做,大多数大公司(如银行)都会对其API进行版本控制,并且仍允许您使用旧版本.所以你的代码永远不会改变.
构建用于UI更改的代码检查.例如,如果你总是希望找到ID为一个HTML元素u_0_n,突然所有的擦伤目前还没有找到这个HTML元素,你的代码应该以某种方式提醒您通过电子邮件,即时通讯,系统日志,一些.
网络抓取通常是快速,肮脏的解决方案.尝试将所有其他可能性首先用尽所有其他可能性,然后再将一些像计费一样重要的事情与像网络抓取一样易变的技
| 归档时间: |
|
| 查看次数: |
733 次 |
| 最近记录: |