On 1/28/2014 9:12 PM, scurvy scott wrote:
Hi guys, I'm trying to figure out why my code won't output to terminal, but will run just fine in interpreter.
I'm using python 2.7.3 on Debian Linux/Crunchbang.

Here is my code.

import requests
from bs4 import BeautifulSoup as beautiful
import sys

def dogeScrape(username, password):
    payload = {'username': username, 'password': password}
r = requests.post("http://dogehouse.org/index.php?page=login";, data=payload)
    soup = beautiful(r.text)
    confirmed = str(soup.findAll('span',{'class':'confirmed'}))
    print "Confirmed account balance: " + confirmed[86:98]

dogeScrape("XXXX", "XXXX")

It will output the "confirmed....." part, just not the confirmed variable. It will output the entire thing in the interpreter.

Good reminder for everyone: be explicit about behavior. We wasted an iteration just to get this clarified.

The expression to be printed is the concatenation of "Confirmed account balance: " with a slice of confirmed. Therefore confirmed is less that 86 characters (or the slice is blank), therefore no output appears. Print the entire value of confirmed; that will tell us a lot.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to