Import data from HTML to MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mfoolb

    #1

    Import data from HTML to MySQL

    Hi,

    I need to import lot of data from html files (all the same layout and
    tables name) to a MySQL db.
    Is there any class that fullfill my needs? What's the fastest way to
    accomplish that?

    TIA for help.

  • The Natural Philosopher

    #2
    Re: Import data from HTML to MySQL

    mfoolb wrote:
    Hi,
    >
    I need to import lot of data from html files (all the same layout and
    tables name) to a MySQL db.
    Is there any class that fullfill my needs? What's the fastest way to
    accomplish that?
    >
    TIA for help.
    >
    You haven't provided enough information to answer the question.

    Comment

    • mfoolb

      #3
      Re: Import data from HTML to MySQL

      You haven't provided enough information to answer the question.
      Well, that's fair..

      here it is the html code (it repeats):

      [...]
      <TABLE WIDTH=100%><TD CLASS=pt>Mainco urses<TR><TD><H R></
      TABLE><TABLE><T R><TD WIDTH=30><TD WIDTH=30><TD WIDTH=30><TD
      WIDTH=30><TD WIDTH=30>
      <TR><TD><TD><TD ><B>Pasta</B<TD><B>Format </B<TD CLASS=cr><B>XXX X</
      B<TD CLASS=cr><B>YYY YYYY</B>
      <TR><TD><TD><TD >Name1 <TD>Name1a <TD CLASS=cr>Q.ta1 <TD
      CLASS=cr>Q.ta1b
      <TR><TD><TD><TD >Name2 <TD>Name2b <TD CLASS=cr>Q.ta2 <TD
      CLASS=cr>Q.ta2b
      [...]
      </TABLE><BR><BR>

      <TABLE WIDTH=100%><TD CLASS=pt>Desser t<TR><TD><HR></
      TABLE><TABLE><T R><TD WIDTH=30><TD WIDTH=30><TD WIDTH=30><TD
      WIDTH=30><TD WIDTH=30>
      <TR><TD><TD><TD ><B>Cake</B<TD><B>Type</B<TD CLASS=cc><B>XXX X</B>
      <TD CLASS=cc><B>YYY YYYY</B>
      <TR><TD><TD><TD >Name1 <TD>Name1a <TD CLASS=cc>Q.ta1 <TD
      CLASS=cc>Q.ta1b
      <TR><TD><TD><TD >Name2 <TD>Name2b <TD CLASS=cc>Q.ta2 <TD
      CLASS=cc>Q.ta2b
      [...]
      </TABLE><BR><BR>

      Thank you.

      Comment

      • macca

        #4
        Re: Import data from HTML to MySQL

        If it was standards complient html maybe you could convert it to XML
        using HTML Tidy or something... would make the job easier to read and
        store in MySQL.



        or


        Read the HTML file into a variable and do some RegEx matching or
        something to extract the data

        Comment

        • The Natural Philosopher

          #5
          Re: Import data from HTML to MySQL

          mfoolb wrote:
          >You haven't provided enough information to answer the question.
          >
          Well, that's fair..
          >
          here it is the html code (it repeats):
          >
          [...]
          <TABLE WIDTH=100%><TD CLASS=pt>Mainco urses<TR><TD><H R></
          TABLE><TABLE><T R><TD WIDTH=30><TD WIDTH=30><TD WIDTH=30><TD
          WIDTH=30><TD WIDTH=30>
          <TR><TD><TD><TD ><B>Pasta</B<TD><B>Format </B<TD CLASS=cr><B>XXX X</
          B<TD CLASS=cr><B>YYY YYYY</B>
          <TR><TD><TD><TD >Name1 <TD>Name1a <TD CLASS=cr>Q.ta1 <TD
          CLASS=cr>Q.ta1b
          <TR><TD><TD><TD >Name2 <TD>Name2b <TD CLASS=cr>Q.ta2 <TD
          CLASS=cr>Q.ta2b
          [...]
          </TABLE><BR><BR>
          >
          <TABLE WIDTH=100%><TD CLASS=pt>Desser t<TR><TD><HR></
          TABLE><TABLE><T R><TD WIDTH=30><TD WIDTH=30><TD WIDTH=30><TD
          WIDTH=30><TD WIDTH=30>
          <TR><TD><TD><TD ><B>Cake</B<TD><B>Type</B<TD CLASS=cc><B>XXX X</B>
          <TD CLASS=cc><B>YYY YYYY</B>
          <TR><TD><TD><TD >Name1 <TD>Name1a <TD CLASS=cc>Q.ta1 <TD
          CLASS=cc>Q.ta1b
          <TR><TD><TD><TD >Name2 <TD>Name2b <TD CLASS=cc>Q.ta2 <TD
          CLASS=cc>Q.ta2b
          [...]
          </TABLE><BR><BR>
          >
          Thank you.
          >
          Still not enough: where is thi code? just in a file that PHP can read ?
          Once or lots of times?

          I still dont understand what you are trying to do here.

          Comment

          • Jerry Stuckle

            #6
            Re: Import data from HTML to MySQL

            mfoolb wrote:
            Hi,
            >
            I need to import lot of data from html files (all the same layout and
            tables name) to a MySQL db.
            Is there any class that fullfill my needs? What's the fastest way to
            accomplish that?
            >
            TIA for help.
            >
            >
            There isn't going to be a class which can take your HTML and import it
            into MySQL (or any other database). But check out the DOM classes - you
            can probably use them to parse your html, then add the data to MySQL
            yourself.

            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Comment

            • McKirahan

              #7
              Re: Import data from HTML to MySQL

              "mfoolb" <marco@neomedia .itwrote in message
              news:1193657450 .895951.305780@ 22g2000hsm.goog legroups.com...
              >
              You haven't provided enough information to answer the question.
              >
              Well, that's fair..
              >
              here it is the html code (it repeats):
              >
              [...]
              <TABLE WIDTH=100%><TD CLASS=pt>Mainco urses<TR><TD><H R></
              TABLE><TABLE><T R><TD WIDTH=30><TD WIDTH=30><TD WIDTH=30><TD
              WIDTH=30><TD WIDTH=30>
              <TR><TD><TD><TD ><B>Pasta</B<TD><B>Format </B<TD CLASS=cr><B>XXX X</
              B<TD CLASS=cr><B>YYY YYYY</B>
              <TR><TD><TD><TD >Name1 <TD>Name1a <TD CLASS=cr>Q.ta1 <TD
              CLASS=cr>Q.ta1b
              <TR><TD><TD><TD >Name2 <TD>Name2b <TD CLASS=cr>Q.ta2 <TD
              CLASS=cr>Q.ta2b
              [...]
              </TABLE><BR><BR>
              >
              <TABLE WIDTH=100%><TD CLASS=pt>Desser t<TR><TD><HR></
              TABLE><TABLE><T R><TD WIDTH=30><TD WIDTH=30><TD WIDTH=30><TD
              WIDTH=30><TD WIDTH=30>
              <TR><TD><TD><TD ><B>Cake</B<TD><B>Type</B<TD CLASS=cc><B>XXX X</B>
              <TD CLASS=cc><B>YYY YYYY</B>
              <TR><TD><TD><TD >Name1 <TD>Name1a <TD CLASS=cc>Q.ta1 <TD
              CLASS=cc>Q.ta1b
              <TR><TD><TD><TD >Name2 <TD>Name2b <TD CLASS=cc>Q.ta2 <TD
              CLASS=cc>Q.ta2b
              [...]
              </TABLE><BR><BR>
              Reformatting the above into one tag per line (see below)
              quicky reveals that the tables are improperly formatted.

              The first <TDis not within a <TR>;
              no closing </TDor </TRtags;
              inconsistent number of columns in a row; et.al.

              I wouldn't count on the pages remaining in this format!

              [...]
              <TABLE WIDTH=100%>
              <TD CLASS=pt>Mainco urses
              <TR>
              <TD>
              <HR>
              </TABLE>

              <TABLE>
              <TR>
              <TD WIDTH=30>
              <TD WIDTH=30>
              <TD WIDTH=30>
              <TD WIDTH=30>
              <TD WIDTH=30>
              <TR>
              <TD>
              <TD>
              <TD><B>Pasta</B>
              <TD><B>Format </B>
              <TD CLASS=cr><B>XXX X</B>
              <TD CLASS=cr><B>YYY YYYY</B>
              <TR>
              <TD>
              <TD>
              <TD>Name1
              <TD>Name1a
              <TD CLASS=cr>Q.ta1
              <TD CLASS=cr>Q.ta1b
              <TR>
              <TD>
              <TD>
              <TD>Name2
              <TD>Name2b
              <TD CLASS=cr>Q.ta2
              <TD CLASS=cr>Q.ta2b
              [...]
              </TABLE>

              <BR>
              <BR>

              <TABLE WIDTH=100%>
              <TD CLASS=pt>Desser t
              <TR>
              <TD>
              <HR>
              </TABLE>
              <TABLE>
              <TR>
              <TD WIDTH=30>
              <TD WIDTH=30>
              <TD WIDTH=30>
              <TD WIDTH=30>
              <TD WIDTH=30>
              <TR>
              <TD>
              <TD>
              <TD>
              <B>Cake</B>
              <TD><B>Type</B>
              <TD CLASS=cc><B>XXX X</B>
              <TD CLASS=cc><B>YYY YYYY</B>
              <TR>
              <TD>
              <TD>
              <TD>Name1
              <TD>Name1a
              <TD CLASS=cc>Q.ta1
              <TD CLASS=cc>Q.ta1b
              <TR>
              <TD>
              <TD>
              <TD>Name2
              <TD>Name2b
              <TD CLASS=cc>Q.ta2
              <TD CLASS=cc>Q.ta2b
              [...]
              </TABLE>

              <BR>
              <BR>


              Comment

              Working...