I am writing a script for my employer to get certain data from their own site. For a long list of reasons, I need to get the data off the site as it is shown. I have discovered, some of that data is retrieved via a js call...
In retrospect, I should have gone with mechanize, but I went with twill (thinking I would have access to mechanize since twill describes itself as a thin-wrapper for mechanize) the project is just one post-call away from completion and I desperately do not want to rewrite all my twill based code for mechanize.
I need to submit a post request that is not attached to a form. So I need mechanize (or a similar lib). According to twill's docs, there should be a mechanize browser object retrievable by the below code:
#after logging in and successfully loading pages
b = get_browser()
mb = b._browser
I get:
AttributeError: 'TwillBrowser' object has no attribute '_browser'
Looking at the source it seems twill's browser is not using mechanize's browser anymore?
So my questions are:
- Is there still a mechanize browser inside twill.
- If so, how do I get it?
- If not, how can I get the cookies from twill to mechanize so I can make request using those cookies?
ideally I'd so something like:
cjar = 'cookies.yaml'
save_cookies(cjar)
mb.open(url, data=data, cookies=cjar)
But I know I need a little more magic than just adding cookies=filename :)