I've been experimenting around on PythonAnywhere trying to get some python to work on a webserver.  I initially switched from Arvixe because they were running 2.4 and PythonAnywhere's name was just too appealing. 

My application consists of two files: phones.py and phonesearch.py.  Together they are supposed to scrape craigslist for phone prices.  

I test locally in 2.7 and it runs just fine, generating an html page (celly.html) with a table and all of the prices.  When I upload it, it generates the html just fine, but refuses to to add anything to my prices list ([intprices]).  

My suspicions: (a) because it works fine locally, PythonAnywhere isn't allowing it to communicate with craigslist; or  (b) because I'm doing this like a caveman and not using a microframework, PythonAnywhere is denying me; or  (c) I am blind to my errors and I have missed something obvious.  

My python scripts are located in /home/tseymour/mysite and the html is generated at same/mysite/static/celly.html.  The file is served up at http://tseymour.pythonanywhere.com/static/celly.html

You'll notice that all of my cells are filled with "N/A" which means it raised an IndexError in the try:" in SearchPhone.py.  This means my lists are being filled! 

But WHY is that?! I believe it is because I am PythonAnywhere n00b.  

Please advise.  

SearchPhone.py

from BeautifulSoup import BeautifulSoup
import urllib
import re

def SearchPhone(phone):

    y = "http://losangeles.craigslist.org/search/moa?query=" + phone + "+-%22buy%22+-%22fix%22+-%22unlock%22+-%22broken%22+-%22cracked%22+-%22parts%22&amp;srchType=T&amp;minAsk=&amp;maxAsk="

    site = urllib.urlopen(y)
    html = site.read()
    site.close()
    soup = BeautifulSoup(html)


    prices = soup.findAll("span", {"class":"itempp"})
    prices = [str(j).strip('&lt;span class="itempp"&gt; $&lt;/span&gt;') for j in prices]

    for k in prices[:]:
        if k == '': #left price blank
            prices.remove(k)
        elif int(k) &lt;= 75: #less than $50: probably a service (or not true)
            prices.remove(k)
        elif int(k) &gt;= 999: #probably not true
            prices.remove(k)

    #Find Average Price
    intprices = []
    newprices = prices[:]
    total = 0
    for k in newprices:
        total += int(k)
        intprices.append(int(k))

    intprices = sorted(intprices)

    try:
        del intprices[0]
        del intprices[-1]


        avg = total/len(newprices)
        low = intprices[0]
        high = intprices[-1]

        if len(intprices) % 2 == 1:
            median = intprices[(len(intprices)+1)/2-1]
        else:
            lower = intprices[len(intprices)/2-1]
            upper = intprices[len(intprices)/2]
            median = (float(lower + upper)) / 2



        namestr = str(phone)
        medstr = "Median: $" + str(median)
        avgstr = "Average: $" + str(avg)
        lowstr = "Low: $" + str(intprices[0])
        highstr = "High: $" + str(intprices[-1])
        samplestr = "# of samples: " + str(len(intprices))
        linestr = "-------------------------------"

    except IndexError:
        namestr = str(phone)
        medstr = "N/A"
        avgstr = "N/A"
        lowstr = "N/A"
        highstr = "N/A"
        samplestr = "N/A"
        linestr = "-------------------------------"

    return (namestr, medstr, avgstr, lowstr, highstr, samplestr, linestr)


phones.py

from SearchPhone import SearchPhone

phones = ["Iphone 4", "Iphone 5","Galaxy s3", "Galaxy s2", "LG Lucid", "LG Esteem", "HTC One S", "Droid 4",
          "Droid RAZR MAXX", "HTC EVO", "Galaxy Nexus", "LG Optimus 2", "LG Ignite",
          "Galaxy Note", "HTC Amaze", "HTC Rezound", "HTC Vivid", "HTC Rhyme", "Motorola Photon",
          "Motorola Milestone", "myTouch slide", "HTC Status", "Droid 3", "HTC Evo 3d", "HTC Wildfire",
          "LG Optimus 3d", "HTC ThunderBolt", "Incredible 2", "Kyocera Echo", "Galaxy S 4g",
          "HTC Inspire", "LG Optimus 2x", "Samsung Gem", "HTC Evo Shift", "Nexus S", "LG Axis", "Droid 2",
          "G2", "Droid x", "Droid Incredible"
          ]

f = open('/home/tseymour/mysite/static/celly.html','w')


f.write("""&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Celly Blue Book&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
""")

#table
f.write('&lt;table width="100%" border="1"&gt;')
for x in phones:
    print "SEarchphone0"
    y = SearchPhone(x)
    print "SEarchphone"
    f.write( "\t&lt;tr&gt;")
    f.write( "\t\t&lt;td&gt;" + str(y[0]) + "&lt;/td&gt;")
    f.write( "\t\t&lt;td&gt;" + str(y[1]) + "&lt;/td&gt;")
    f.write( "\t\t&lt;td&gt;" + str(y[2]) + "&lt;/td&gt;")
    f.write( "\t\t&lt;td&gt;" + str(y[3]) + "&lt;/td&gt;")
    f.write( "\t\t&lt;td&gt;" + str(y[4]) + "&lt;/td&gt;")
    f.write( "\t&lt;/tr&gt;")

f.write('&lt;/table&gt;')

f.close()


Also, I did upload beautifulsoup just incase


Question: Is it okay to vacuum a laptop keyboard?
Answer: There are small (usually USB-powered) vacuums that you can use that do not generate enough force, nor have large enough intakes, to suck the keys of the board.

Most laptops keyboards have pop-off keys and a normal vacuum will take those keys right off. Those that have what are sometimes called "chiclet" keys do not generally pop off and should be safe from this particular hazard.

However, a more serious problem is the static charge that the friction from the airflow will create. For this reason it is never recommended to use a normal vacuum for cleaning any computer, ever. Canned air does not create this problem, and there are special electronics vacuums that are properly grounded and use other special components that are much less likely to generate enough of a static charge to damage the sensitive electronic components in a computer. Even these electronics vacuums, though, have no protection against sucking keys off keyboards.

For these reasons, I would recommend against using a vacuum to clean any part of any computer. Canned air should be sufficient for your needs. It's also cheap.