Curling, just not Canadian Style Python 2.6.6 and the urllib2 library

In bash, getting a web page

curl http://web-atlanta.com/ >html.html

The bash curl command has nothing to do with Canadian Curling, which is like shuffleboard on ice amidst the tension garnered tolerating a joke about the Queen or the national health care system from a surfboard riding processed cheese eating upper Mexican from south of the barbarian line. In bash, curl is short for client url, a simple http request of a web address.

In Python

x = urllib2.urlopen("http://web-atlanta.com")
w = x.read()

And as a part of a class init

  def __init__(self,TableName,filename,url):
    self.sqhandle=sqlite3.connect(filename) # empty if noexist
    self.sq1cursor = self.sqhandle.cursor()
    self.filename = filename
    try:
      self.sq1cursor.execute('''CREATE TABLE '''
         +TableName+''' (somenum real, somestring text)''')
      self.sqhandle.commit()
    except:
      print TableName,"table already exists"
    self.samples = 0
    x = urllib2.urlopen(url)
    self.pagedata = x.read()

So if we instantiate a class we now have the html as classname.pagedata and sqlite3 handle and cursor as classname.sqhandle and sq1cursor

We need to do some things with sql like

    command = 'INSERT INTO '+table+' VALUES (' + x +', "'+ y +'")'
    try:
      classname.sq1cursor.execute(command)
      classname.sqhandle.commit()
    except:
      print command

sqlite3 insert a row

  def sqlinsert(sqhandle,sq1cursor,table,x,y):
    command = 'INSERT INTO '+table+' VALUES (' + x +', "'+ y +'")'
    try:
      sq1cursor.execute(command)
      sqhandle.commit()
    except:
      print "failed to ", command

0 thoughts on “Curling, just not Canadian Style Python 2.6.6 and the urllib2 library”

  1. I see your site needs some fresh & unique content. Writing manually is time consuming, but there is solution for
    this. Just search for: Masquro is strategies

  2. Howdy! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I am using the same blog platform as yours and I am having difficulty finding one? Thanks a lot!

  3. I am usually to blogging and i really respect your content. The article has actually peaks my interest. I am going to bookmark your site and keep checking for brand new information.

  4. Hello! I just wanted to ask if you ever have any problems with hackers? My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no backup. Do you have any methods to protect against hackers?

  5. My brother recommended I might like this website. He was totally right.
    This post actually made my day. You can not imagine simply how much time I had spent for
    this information! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *