Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion HTML Forms Inputs

Html to Python

For work I need to transfer data from a HTML form to a python script that can apply the math needed to the data. How do I get the data from the HTML to be moved over to the python script?

1 Answer

Are we talking about website scraping or server-side Python?

In website scraping, a Python script that you write visits a webpage, downloads the HTML as a string, and then parses it for content it needs, doing whatever changes it has to before spitting the final product out somewhere. There are a lot of libraries that can help you with this; I'm not too familiar with it myself. A quick Google search should get you a long way. Maybe this can get you started.

With server-side Python, you're using the language a lot like PHP. I haven't really studied Python a whole lot, but my guess is that Python provides a class or set of classes for interacting with forms, GET/POST variables, and the like. Again, I'm not that familiar with Python (it's on my to-do list), but I'm sure that Google has a lot more information on the subject.

I did a quick search myself, actually; here's what I turned up:

On Website Scraping | On Forms with Server-side Python