By Tom Meagher / @ultracasual
Cover more ground, faster
Helps document reporting
Makes analysis replicable
Automation!
Git or Github
pip or virtualenvs
Frameworks
This will not be nuanced, idiomatic Python.
Some programmers may be saddened by this code.
But you know what? If it works, and it works on deadline, that's what matters for us today.
To start thinking about
how to break problems down
into the smallest tasks
that can be programmed.
You can learn to program.
Easy to learn.
Explicit.
Mature and well-documented.
Strong PythonJournos community of support.
#create and activate a sandbox to work in
mkvirtualenv ire15
#clone the code repo from Github
git clone git@github.com:tommeagher/pythonIRE15.git
#install the dependencies: requests, beautifulsoup4, unicodecsv
pip install -r requirements.txt
#launch the interactive interpreter
ipython
Strings are ordered sequences of characters wrapped in quotes.
var1 = "This class is at IRE in Philadelphia."
var2 = "&You!_123 Four"
Numbers that you can do math on.
Integers are whole numbers.
Floats are decimals.
my_list = [1, 2, "Liberty Bell"]
my_dict = {'Fruit': 'Orange', 'Weight': 10}
Logic that can trigger other operations,
similar to Excel's if function.
score = 1
if score > 2:
print "Win"
else:
print "Lose"
For more practice with the basics,
try this tutorial from PyCAR, or this one.
Open your text editor of choice and a terminal window.
Write a line or two of code under each comment,
save the text file and then try to run:
python scrape1.py
Now, expand your code to scrape a similar, but bigger page.
We probably won't have time to get to these.
But if you want to keep working,
try the extra, extra credit project here.
And you can find the working scripts in the completed dir.
Excellent post on ethics of scraping
More resources for learning Python
Github
StackOverflow
Clone the source code