HACK THE web WITHOUT A browser


It is a traditional problem. You want data for utilize in your program however it is on a webpage. Some sites have an API, of course, however usually, you are on your own. You can tons the whole page through HTTP as well as parse it. Or you can utilize some tools to “scrape” the site. One fascinating method to do this is woob — web outside of browsers.

The system utilizes a series of backends tailored at specific sites. There’s a collection of official backends, as well as you can likewise produce your own. when you have a backend, you can configure it as well as utilize it from Python. Here’s an example of discovering a bank account balance:

>>> from woob.core import Woob
>>> from woob.capabilities.bank import CapBank
>>> w = Woob()
>>> w.load_backends(CapBank)
{‘societegenerale’: , ‘creditmutuel’: }
>>> pprint(list(w.iter_accounts()))
[,
,
]
>>> acc = next(iter(w.iter_accounts()))
>>> acc.balance
Decimal(‘87.32’)
The listing of offered backends is impressive, however eventually, you’ll want to produce your own modules. Thankfully, there’s lots of documentation about exactly how to do that. The framework enables you to publish data to the site as well as quickly checked out the results. Each backend likewise has a test which can find if a modification in the site breaks the code, which is a typical issue with such schemes.

We didn’t see a Hackaday backend. as well bad. There are, however, numerous application examples, both console-based as well as utilizing QT. For example, you can browse for movies, handle recipes, or dating sites.

Of course, there are numerous methods possible to this problem. perhaps you requirement to discover out when the next train is leaving.

Leave a Reply

Your email address will not be published. Required fields are marked *