background preloader

Python

Facebook Twitter

Mechanize – Writing Bots in Python Made Simple by Guy Rutenberg. I’ve been using python to write various bots and crawler for a long time.

mechanize – Writing Bots in Python Made Simple by Guy Rutenberg

Few days ago I needed to write some simple bot to remove some 400+ spam pages in Sikumuna, I took an old script of mine (from 2006) in order to modify it. The script used ClientForm, a python module that allows you to easily parse and fill html forms using python. I quickly found that ClientForm is now deprecated in favor of mechanize. In the beginning I was partly set back by the change, as ClientForm was pretty easy to use, and mechanize‘s documentation could use some improvement. However, I quickly changed my mind about mechanize. For future reference for myself, and as another code example to mechanizes sparse documentation I’m giving below the gist of the simple bot I wrote: This isn’t a complete code example, as the rest of the code is just mundane, but you can clearly see how simple it is to use mechanize.

The interesting parts are: Related. Book Review: Python For Kids – A Playful Games Development Introduction For Kids. Personally, I consider programming as a fundamental right.

Book Review: Python For Kids – A Playful Games Development Introduction For Kids

The programming will teach children problem solving and reasoning skills. So, if you have gifted kid or nephew who is about to turn 10 or 11, gift him Python for kids book. The book introduces kids to the basic concepts of Python programming. The kids require no previous programming experience. However, must understand basic math concepts. Part I: Learning to Program : First, book will cover the installation of Python on Windows 7, Mac OS X, and Ubuntu. Conclusion The book is engaging and full of colors to keep young reader engaged in their programming adventure. Info: * Title: Python for Kids * Author: Jason R.

Pros: + Easy to read. + Clear explanations. + Good collection of programming puzzles for kids. + Requires no previous programming experience. Cons: - Very little PyGame coverage and no 3D programming / drawing coverage. Getting Started with Pyvot — Pyvot 0.1.2 documentation. The Pyvot API is exposed in the xl package: See Installation if you can’t yet import Pyvot.

Getting Started with Pyvot — Pyvot 0.1.2 documentation

First steps: Python to Excel and back again Pyvot enables easy transit of data between Python and Excel. For example, we can move a list of Python values to Excel, view and manipulate the data, and retrieve the new version. In a symmetric and equally common usage, we can grab and process Excel values in Python, and display the result to Excel.

Python to Excel >>> xl.Workbook() # Create empty Excel workbook, stored as the 'active' workbook>>> a = range(1,10) # some Python array>>> a[1, 2, 3, 4, 5, 6, 7, 8, 9]>>> xl.view(a) # show Python array in Excel (active workbook) The Python array is copied into Excel. Excel to Python Retrieving data from Excel requires an xl.Range object (see Ranges in Detail), which represents the cells on which to operate. Note that view chose the entirety of column A (sans header) to store our list, but Range.get assumed we only wanted its useful data. Prettyplotlib: Painlessly create beautiful matplotlib plots. Performing Under Pressure, pt. 1: Load-Testing With Multi-Mechanize.

Many types of performance problems can result from the load created by concurrent users of web applications, and all too often these scalability bottlenecks go undetected until the application has been deployed in production.

Performing Under Pressure, pt. 1: Load-Testing With Multi-Mechanize

Load-testing, the generation of simulated user requests, is a great way to catch these types of issues before they get out of hand. Last month I presented about load testing with Canonical's Corey Goldberg at the Boston Python Meetup last week and thought the topic deserved blog discussion as well. In this two-part series, I'll walk through generating load using the Python multi-mechanize load-testing framework, then collect and analyze data about app performance using Tracelytics. Also, a request: there's mechanize documentation available, but I unfortunately haven't found any full documentation of the python mechanize API online-post a comment if you know where to find it! Enter multi-mechanize. A simple mechanize script There's one more thing: custom timers. Python: How to use Mechanize Cheat Sheet.