I'm ready to write a program to analyze some statics in webpages,
and I found many python library for HTML DOM parsing such as html5lib, Beautiful Soup...
However, I found it hard to access browser object like window
object by python.
Is it possible to use python to fetch browser object just like javascript?
e.g window.location
Any ideas?
Thanks
Asked
Active
Viewed 1,031 times
1

YeJiabin
- 1,038
- 1
- 9
- 17
-
3When parsing HTML from Python, there's no browser window you could possibly access. I don't understand what you are trying to do. – Sven Marnach May 30 '11 at 11:28
-
@Sven Marnach Can python set user agent option like `curl --user-agent`? – YeJiabin May 30 '11 at 11:33
-
@YeJabin: That's a completely separate question, and can be answered with a Google or SO eacrh in just a few seconds: http://stackoverflow.com/questions/802134/changing-user-agent-on-urllib2-urlopen – Sven Marnach May 30 '11 at 11:51
2 Answers
0
It's impossible. The window object is available only for JavaScript code running inside a browser, but you are parsing a HTML file in a Python script. Maybe you should ask a more specific question explaining in more detail what are you actually trying to achieve.

Adam Byrtek
- 12,011
- 2
- 32
- 32