Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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