I´m running a html page on a server (using Xampp). Now, I would like take a variable from this html and pass it to python but i don´t the way. I don´t know if I can use Flask because I am running the html with Xampp.
Thank you!
Related
I have created a button in HTML , i want to invoke a external python script when that button is clicked.
and also pass on some variables into that python script if possible.
which method would be the simplest and fastest.
TIA
I tried flask but that didnt help me, my html code is being hosted on apache. i cannot / shouldn't (maybe) use flask
If you are not using Flask, you can use Django. If you don't want to use Django either, you can use ajax to call the script as Fastnlight has shown above.
In case that does not work, you can use "py-script". It is like javascript. It is in experimental phase but can do simple tasks in your browser window.
link to pyscript: https://pyscript.net/
I am new to web-sites field and I was wondering if you can make a simple personal website using only python (NO HTML, CSS, JS) and flask. I was searching a bit on the internet and didn't find any good examples.
Is it possible? And if it is any code examples?
I vould appreciate if you have any suggestions or exaples.
Here is what I want my website to look like(it doesn't need to have this many functions): https://palletsprojects.com/
Flask can be used for making realy simple websites with only basic text on them. But if you want a more developed website with more functions and a nicer desing you need to use html and css, and than you can use flask and python to implement 'logic' to them.
Here is a python flask tutorial:https://www.youtube.com/watch?v=MwZwr5Tvyxo
I have a problem getting javascript content into HTML to use it for scripting. I used multiple methods as phantomjs or python QT library and they all get most of the content in nicely but the problem is that there are javascript buttons inside the page like this:
Pls see screenshot here
Now when I load this page from a script these buttons won't default to any value so I am getting back 0 for all SELL/NEUTRAL/BUY values below. Is there a way to set these values when you load the page from a script?
Example page with all the values is: https://www.tradingview.com/symbols/NEBLBTC/technicals/
Any help would be greatly appreciated.
If you are trying to achieve this with scrapy or with derivation of cURL or urrlib I am afraid that you can't do this. Python has another external packages such selenium that allow you to interact with the javascript of the page, but the problem with selenium is too slow, if you want something similar to scrapy you could check how the site works (as i can see it works through ajax or websockets) and fetch the info that you want through urllib, like you would do with an API.
Please let me know if you understand me or i misunderstood your question
I used seleneum which was perfect for this job, it is indeed slow but fits my purpose. I also used the seleneum firefox plugin to generate the python script as it was very challenging to find where exactly in the code as the button I had to press.
I am a python beginner and I need some help to create a web service that calls a python web scraping script (a task for a course).
I can use Bottle to create the web service. I wanted to use static_file to call the script but I am not sure about that because the documentation says that static_file is for CSS.
The idea is first to create the web service and later used the web scraping script from a server.
Thanks for your help and greetings from Colombia!
P.S. I don't have an excellent English but I hope someone can understand me and help me.
unless it's already in a function, edit your scraping script so your code is contained within a function that returns whatever information you want. it should be as easy as indenting everything unindented and adding a def main():
let's say your script is called scraper.py and it's located along with your bottle controllers, at the top of your controller file add a import scraper.
in your callback you can call scraper.main()
(not sure why pasting the code here is not formatting it's below)
Having that said, it's usually bad practice to have something long running like a scraping script in a request. You'd usually want to use a queue of scraping jobs where your controller posts work to do, your scraper subscibes to it and notifies it when it's done caching the results somewhere.
from bottle import route, run
import scraper
#route('/scrape')
def scrape():
return scraper.main()
you could try this guide I found:
http://docs.python-guide.org/en/latest/scenarios/scrape/
For the xpath stuff, I would suggest using Mozilla Firefox with the "Firebug" pluggin. It can generate xpaths for you which will help you write your script faster
I am making a program where I need to get information from a web server (I'm using Django) and then I'd send data back to the server.
The thing is I can only find ways to get information from the html page of the url I requested.
How could I use a Python script to get data from the web server? (like making a Django db query but outside Django, using only Python) I want to be able to get the information stored in Django without having to go directly to the website (that is, using a Python script).
Thanks in advance,
I guess you'll want to use a REST framework. The most used are django-rest-framework and tastypie