[DB-SIG] importing data from an HTML page to access

Chou, Abc abchou@wharton.upenn.edu
Fri, 21 Jun 2002 18:28:56 -0400


hi,

we are having trouble with importing data from a webpage onto access.  the main problem is trying to enter data into successive fields.

we are just beginners, and listed below is what we have so far.  we would really appreciate any suggestions on what the next step is to import the next rows of data into the database.

here is the code.
thanks for any help you can give us.

import string
import urllib, re
import win32com.client
engine=win32com.client.Dispatch("DAO.DBEngine.36")
db=engine.OpenDatabase(r'z:\Case 3\Case3.mdb')
ob = urllib.urlopen('http://opim.wharton.upenn.edu/~opim101/spring02/Plant1.html')

#rs = db.OpenRecordset("TotalPlantDemand")
bs = ob.readlines()

a1 = 0
ind = 3
#for i in range(rs.Fields.Count):
for s in bs:
    rs = db.OpenRecordset("TotalPlantDemand")
    str = bs[3:]
    b1 = string.split(str[0], ',')
    b2 = b1[0:]
    l1 = b2[0]
    #l2 = string.split(l1[4], ' ')
    orderid = l1[4:9]
    for s in bs:
        db.Execute("insert into TotalPlantDemand values("+(orderid)+",'+#(b2[1])#+',"+(b2[2])+","+(b2[3])+","+(b2[4])+")")
    #rs.MoveNext()
    #print orderid
    #print b2[1:]
    a1+=1