I am trying to retrieve links programatically that use javascript for their retrieval. For this purpose I have decided to use Selenium which has been suggested by many for this purpose. The machine is command line based linux machine on which I am going to execute has Python2.4 ruby1.8.5 and perl 5.8.8 and I can strictly use the above mentioned versions only for this task in any programming language mentioned.
Being an absolute beginner I am getting confused with lot of terms with selenium and its compatibility with the above mentioned 'versions' of programming language. I tried reading http://docs.seleniumhq.org/docs/03_webdriver.jsp but was just lost in all those terms related to selenium. Also my purpose in not actually testing my web application. So for my simple purpose of just executing javascripts that retrieve links is there any step by step approach that a beginner like me should know and follow?
Have you looked at the WWW::Selenium module?
Related
I am wondering if there is a way to to navigate Python(Django) code in Emacs similar to how one can M-. for Common Lisp code when using SLIME.
I have installed ELPY and a mode called python-django. However, they do not seem to provide this functionality.
I am particularly interested in doing this why developing using Django. However, even navigation for standalone Python projects would be nice.
I will give dumb-jump a chance.
It is not as fancy as other go-to-definition methods, as it only searchs for some predefined regex in your project. But it simply works most of the time, and you can add your own regex if you need them.
I made my own game in python using turtle graphics and I want to convert it to an executable file to run in HTML, is there any additional information I should know
Edit: An executable is not likely what you're looking for per Chris' answer. He also provides info about making an installer, if you do want to accomplish that. My answer addresses getting your Python game running in the browser.
When I initially saw this question, I thought it wasn't a thing. However, Python is just a language. Anything can interpret and run Python logic. It's just a matter if someone has built something that works in the browser and interprets Python.
After some Google searching, I found Skulpt: http://www.skulpt.org/. It appears to be a Javascript implementation of a Python interpreter. This is important because browsers only understand Javascript, not Python.
Something worth noting is that Skulpt appears to only have partial support for Python 3. It mostly focuses on Python 2. This could be a major concern because Python 2 is scheduled for end of life January 1st, 2020 (at least, that's what pip told me).
There are examples of using Skulpt on its page. Heads up that you'll likely need to learn some amount of Javascript, but if you're comfortable with Python already, that shouldn't be terrible.
Edit:
There also appears to be Brython: https://brython.info/. This is a Python 3-focused implementation. At first glance, it looks a little easier to use, too.
Hope this helps!
Please know that executables (.exe) & browsers tend not to work together.
See this stackoverflow question referring to .exe's & html The long & short of it is that you can setup .exe's so they can be downloaded, but not rendered in the browser.
If you want to convert your script to a .exe file, you'll need something like pyinstaller. Here's a link to some info about installing & using it.
TheBeege's answer is on point with rendering in the browser with python when you already have code written with turtle. I just wanted to make sure anyone coming here looking for info on python with executables could find it.
I am writing a script to log into web pages (I know it's a bad idea, and I don't care), but I need to run it with a bookmark from Firefox. Does anyone know how to help me?
There is no pre-made solution and as it stands, you left part of your question ambiguous.
But here is one possible outline on how you could accomplish what you want from completely inside firefox.
First off you need to get python in the browser, but it is normally compiled into machine code. The solution is the Transcrypt project, which is Python is transcompiled into javascript and that script is then loaded into your browser. This allows you to run python code.
Extensions to python are made so it can access the DOM in a similiar way you can from javascript.
The transcrypt website has some examples, and some more can be found at a draft page at Mozilla.
Your bookmarklet would be to load a script to load transcrypt and feed it your python code, something like
javascript:(function(){var el=document.createElement('script');el.src='file:///something/something/transcript_loader_and_my_python_code.js';document.body.appendChild(el);})();
But the exact bookmarklet would depend on how you go about things. Writing transcript_loader_and_my_python_code.js is on your own, but if you get the examples from the links above working it should be trivial.
I've just started learning a bit of Python and I'm currently trying to implement a Python UI through HTML. Is there anything in vanilla Python that would allow for this, similar to how you can create UI's with Java and XML with JFX or will I have to use a framework such as Django?
I'm reluctant to use Django as there are many features that I do not need
Thanks,
Michael
In vanilla python wsgiref is very helpful for building the server-side of web-applications (possibly with str.format or string.Template and/or json) but if you want it more direct communication I would suggest XML-RPC (there are good js-clients out there).
It is also possible to execute Python Scripts right in your Website with Brython or (with strong constraints) Ironpython
For Windows you can build HTML Applications with Ironpython (have not tried but in theory it should work) or Brython (if you dont want to require the user to have ironpython installed)
You can also use Pyjs to build applications but while it uses html and javascript, i think it you dont see much of it.
There are HTML things in some ui-libraries like in wxpython (I am quite sure you will find them in many libraries)
I recently wanted to port my scraper that uses mechanize.Browser to Python 3. I haven't found any python3-mechanize package or anything like that. I'm not yet familiar with Python module building with some special procedures so I don't know how would I use 2to3 there. Any suggestions?
#edit:
I'm accepting Sibi's answer because it is currently the best. I will be pleased to award any other answer this way, if it just points to a better solution.
There's been no activity in the Mechanize repository for several years. Despite the experimental Python 3 branch suggested, it has not been merged and there is no official response to the request for support.
If you're looking for an active project, you may wish to look elsewhere. Two similar projects compatible with Python 3 are
MechanicalSoup - "A Python library for automating interaction with websites."
RoboBrowser - "a simple, Pythonic library for browsing the web without a standalone web browser."
Both use Requests and BeautifulSoup. As of mid-2015, the latter shows slightly more activity.
This is the experimental Python 3 branch of Mechanize: https://github.com/adevore/mechanize/tree/python3
Also see this for more details: http://web.cecs.pdx.edu/~adevore/mechanize/